[R] sqlSave()
Dieter Menne
dieter.menne at menne-biomed.de
Sun May 10 10:04:39 CEST 2009
Felipe Carrillo <mazatlanmexico <at> yahoo.com> writes:
> I have created a MS Access table named 'PredictedValues' through the statement
below:
> myDB <- odbcConnectAccess("C:/Documents and Settings/Owner/Desktop/Rpond
> Farming.mdb",uid="admin",pwd="")
> sqlSave(myDB,PredictedValues,rownames=FALSE)
> close(myDB)
>
> But if I run the code again with new values I get the message below:
> Error in sqlSave(myDB, PredictedValues, rownames = FALSE) :
> table ‘PredictedValues’ already exists
> and my new records don't get updated.
>
> I was under the impression that 'sqlSave' would copy new data on top of the
existing one or if the table didn't
> exist it would create one with the new values. I tried 'sqlUpdate' but my
existing 'PredictedValues'
> didn't update. What am I doing wrong.
Either try safer = FALSE (great white shark) or append=TRUE (depending on what
you want).
sqlSave(safer = FALSE) uses the 'great white shark' method of testing tables
(bite it and see). The logic will unceremoniously DROP the table and create it
anew with its own choice of column types in its attempt to find a writable
solution. test = TRUE will not necessarily predict this behaviour. Attempting to
write indexed columns or writing to pseudo-columns are less obvious causes of
failed writes followed by a DROP. If your table structure is precious to you
back it up.
More information about the R-help
mailing list