[R] Passing dynamic sql statement to RODBC functions

Johannes Ranke jranke at uni-bremen.de
Thu Sep 5 08:50:12 CEST 2002


Hi Lingyun


> Does anyone know how to pass dynamic sql statement to RODBC function
> "odbcQuery()" or "sqlQuery()"?
> eg.: under R session, I did:
> >library(RODBC)
> >channel<-odbcConnect(...)
> >data1<-2.5
> >data2<-5.0

I would try something like:

?paste
query <- paste("INSERT INTO xxx VALUES ('",data1,"','",data2,"')",sep="")
sqlQuery(channel,query)

Johannes Ranke

> I want to construct the INSERT sql statement using variables "data1" and
> "data2"  and pass this statement to odbcQuery() . Can I do this? what's the
> syntax to construct this sql statement?
> 
> Thanks
> 
> Lingyun
> 
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list