Seeliger.Curt at epamail.epa.gov
2009-Mar-19 00:04 UTC
[R] R crashes while appending to a created table from SQL Server
Folks,
The code below reliably crashes an R 2.8.1 session on XP when connected to
an SQL Server 2005 database. The problem arises when appending data using
sqlSave() with rownames=FALSE to a table that had been previously created
with rownames=TRUE. Certainly it's daft to do this as a regular
procedure, but it would be useful for R to catch the error in a more
graceful manner.
require(RODBC)
lakes <- odbcConnect('Lakes',uid='cseelige')
ss <- data.frame('a'='1234','b'='5678',
c=9012, stringsAsFactors=FALSE)
sqlDrop(lakes, 'foofooB')
sqlSave(lakes, ss, 'foofooB', append=TRUE)
sqlSave(lakes, ss, 'foofooB', append=TRUE)
sqlSave(lakes, ss, 'foofooB', append=TRUE, rownames=FALSE)
# That last sqlSave() produces an error, which seems to indicate that
# the table is forever munged even though you sqlDrop() it:
# Error in sqlSave(lakes, ss, "foofooB", append = TRUE, rownames =
FALSE) :
# unable to append to table ?foofooB?
sqlDrop(lakes, 'foofooB')
sqlSave(lakes, ss, 'foofooB', append=TRUE)
sqlSave(lakes, ss, 'foofooB', append=TRUE, rownames=FALSE)
# That last line causes the crash.
--
Curt Seeliger, Data Ranger
Raytheon Information Services - Contractor to ORD
seeliger.curt@epa.gov
541/754-4638
[[alternative HTML version deleted]]