AW: [R] Passing dynamic sql statement to RODBC functions
RINNER Heinrich
H.RINNER at tirol.gv.at
Thu Sep 5 08:35:57 CEST 2002
You could construct your SQL statement as a character string using paste()
and pass this as an argument to sqlQuery.
Maybe something like this will work for you:
>data1<-2.5
>sql.statement <- paste("SELECT * FROM somewhere WHERE something=", data1,
";", sep="")
>library(RODBC)
>channel <- odbcConnect(...)
>sqlQuery(channel, query = sql.statement)
>odbcClose(channel)
-Heinrich.
> -----Ursprüngliche Nachricht-----
> Von: Lingyun Shi [mailto:Lingyun.Shi at fimat.com]
> Gesendet: Mittwoch, 04. September 2002 23:41
> An: r-help at stat.math.ethz.ch
> Betreff: [R] Passing dynamic sql statement to RODBC functions
>
>
>
> Hi,
>
> 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 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