Hi everyone,

I am trying to automate (on a Win7 system) an R script to read data from a
DB2 data base and write it to file, for processing by another system. My
code runs in the R gui perfectly. So I wrote a batch file to call this .r
file and output results to script.out as shown below. When I double click
the batch file everything runs successfully. When I schedule a task to run
the batch file, the R code runs, collects data from DB2 data base, but the
write to file fails every time, only save the header from sql query.

R Code:

library(RJDBC)
library(rJava)
jcc = JDBC("com.ibm.db2.jcc.DB2Driver",".../db2jcc4.jar")
conn = dbConnect(jcc,"xxx",user="xxxx",password="xxxx")
bd1 = dbSendUpdate(conn, "set current schema PRODUCCION")
bd1 = dbSendQuery(conn,
paste("SELECT *
FROM VW_tabla_1"))
dat4<- fetch(bd1, n = -1)
write.csv2(dat4,file = ".../bd1.csv",row.names = F)
dbDisconnect(conn)


batch file code:

\Program Files\R\R-3.0.1\bin\x64\R.exe" CMD BATCH --vanilla --slave
"C:\Users\abg\SkyDrive\Documents\dat.R"


thanks.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to