[R] RODBC sqlSave with DB2

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat May 30 08:31:53 CEST 2009


On Fri, 29 May 2009, Elaine Jones wrote:

> I am running R version 2.8.1 on  Windows XP OS.
>
> This works fine. (Data.frame dta is created with records from the DB2
> table.):
>
> sql <- "select * from storage.testappend_slt order by uut"
> dta <- sqlQuery(channel,sql)
>
> But when I try to append records (from data.frame newdta) to the same DB2
> table. I get an error:
>
> sqlSave(channel, newdta, tablename = storage.testappend_slt, append = TRUE,
> +         rownames = FALSE, colnames = FALSE,
> +         verbose = FALSE, oldstyle = FALSE,,
> +         safer = TRUE, addPK = FALSE, typeInfo, varTypes,
> +         fast = TRUE, test = FALSE, nastring = NULL)
>
> Error in sqlSave(channel, dta, tablename = storage.testappend_slt, append =
> TRUE,  :
>  object 'storage.testappend_slt' not found
>
> I've tried variations on the table name including dropping the schema,
> using all uppercase, adding the tablespace name, etc., all without success.

Maybe you did not try giving the name as a character string (in 
quotes)?  For the help:

tablename: character: a database table name accessible from the
           connected dsn.  If missing, the name of 'dat'.

You gave the name of a non-existent R object and got an R error 
message.

> I searched R help and found similar problems have been encountered with
> Oracle and postgresSQL.

No, other probems what you may get when you want to use a schema: 
maybe try to get what you want to do to work without one first?

>      http://www.mail-archive.com/r-help@r-project.org/msg19386.html
>
> The approach in the above link looked promising, but I don't know how to
> set the search path for DB2...

Which is not an R question, and surely you someone posting from 
ibm.com can get help on an IBM product elsewhere.

>
> Additional information, possibly helpful?
>
>> odbcGetInfo(channel),
>       DBMS_Name              DBMS_Ver    Driver_ODBC_Ver
> Data_Source_Name        Driver_Name       Driver_Ver         ODBC_Ver
>     "DB2/AIX64"         "08.02.0005"       "03.51"
> "QUALITY8"              "DB2CLI.DLL"     "08.02.0006"     "03.52.0000"
>
> Server_Name
>      "DB2     "
>
>
> Any suggestions for how to resolve are appreciated!
>
> **************** Elaine McGovern Jones ************************
>
> ISC Tape and DASD Storage Products
>     Characterization and Failure Analysis Engineering
>       Phone:  408  284 4853  Internal: 3-4853
>       jones2 at us.ibm.com
>
>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list