Skip to content
Prev 305427 / 398506 Next

Paasing values to sqlQuery like SAS macro

On Fri, Sep 14, 2012 at 3:54 AM, ramoss <ramine.mossadegh at finra.org> wrote:

            
Almost certainly, but you may have to provide more detail about what
you want (and it's a good idea to mention what package sqlQuery is in,
when asking a question like this)

One approach, based on a guess about what you want, is to take each
value in turn and use gsub() or paste() to put them into a query
string.  For example

queries<-paste("select x, y, z, firm, date from the_appropriate_table
where firm=", firms," and date>=", begindts, " and date <=", enddts)
lapply(queries, sqlQuery, channel=my.database.connection)

will return a list of data frames, one for each set of values.

   -thomas