[R] New RODBC: a problem with sqlSave
Vittorio
vdemart1 at tin.it
Fri Feb 2 15:57:04 CET 2007
Till yesterday I was more than satisfied by RODBC, specifically by
sqlSave which I had been happily using in a daily crontab R batch job
regularly updating a postgresql db for as long as one year. In this R-
batch I was able to save records into indexed tables *** even though
*** they already existed. in this case sqlSave simply neglected those
rows of the input table that were offending the constraints of existing
rows of a table, only appending the *** very new *** rows.
Yesterday I
updated the R packages in my unix box including RODBC and running the R
batch the following error popped up ((I only added the verbose option
to sqlSave!)
====================================================
sqlSave(canale, tabella1, tablename="tminmax", rownames=FALSE,
varTypes=tipicampitminmax, append=TRUE,fast=TRUE,verbose=T)
Query:
INSERT INTO tminmax ( data, cod_wmo, tipo, t ) VALUES ( ?,?,?,? )
Binding: data: DataType 9
Binding: cod_wmo: DataType 1
Binding: tipo:
DataType 1
Binding: t: DataType 2
Parameters:
no: 1: data 2007-01-
26/***/no: 2: cod_wmo 16045/***/no: 3: tipo MIN/***/no: 4: t -2.5/***/
sqlwrite returned
[RODBC] Failed exec in Update
01000 -1 [unixODBC]
Error while executing the query (non-fatal);
ERROR: duplicate key
violates unique constraint "data_cod_tipo"
Query: DROP TABLE tminmax
Errore in sqlSave(canale, tabella1, tablename = "tminmax", rownames =
FALSE, :
unable to append to table 'tminmax'
===========================================
It seems to say that the
violation caused a non-fatal error nevertheless it stopped the batch
job without going on!
What should I do?
Ciao
Vittorio
PS Eliminating
from the original postgresql the offending records, of course, the
above mentioned sqlSave command works like a charme!
More information about the R-help
mailing list