[R-sig-DB] binding variable in sqlQuery
Prof Brian Ripley
r|p|ey @end|ng |rom @t@t@@ox@@c@uk
Wed Dec 6 12:04:24 CET 2006
Simply in R: use paste() to prepare the query,
On Tue, 5 Dec 2006, d. sarthi maheshwari wrote:
> Dear Sir/Madam,
>
> How can we bind a variable value with sqlQuery. For example:
>
> i am trying to run following command ::
>
> library(RODBC)
> inchannel <- odbcConnect("my_server", uid="samay")
> sqlQuery(inchannel, 'select item1, item2 from _my_table
> where item3 >= 10
> and dbid = 10')
>
> however for introducing flexibility i want to write this command as
>
> my_value = 10
> library(RODBC)
> inchannel <- odbcConnect("my_server", uid="samay")
> sqlQuery(inchannel, 'select item1, item2 from _my_table
> where item3 >= 10
> and dbid = my_value')
>
>
> How can I bind the my_value with the query in sqlQuery?
>
> Please suggest and help me. I am in need.
>
>
--
Brian D. Ripley, ripley using 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-sig-DB
mailing list