Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.LNX.4.64.0612061103570.6922@gannet.stats.ox.ac.uk>
Date: 2006-12-06T11:04:24Z
From: Brian Ripley
Subject: binding variable in sqlQuery
In-Reply-To: <d4327f7e0612050051r471386e1hada8d1fe9c187adb@mail.gmail.com>

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 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