I am trying to pass same parameters multiple times in R SQL query. The query is:
table_x <- c(‘Rain’, ‘Cloudy’)
df <- dbGetQuery(conn, "select schemaname, tablename, dateupdated, test_result from weather
Where dateupdated in (select max(dateupdated) from weather where conditions in (?,?))
and dateupdated = sysdate
and conditions in (?,?)",
params= table_x)
The query works if I remove the 2nd conditions clause. Otherwise it complains
Query requires 4 parameters; 2 supplied
I tried creating another vector and pass that through along with 1st vector but still getting same error. Any suggestions.
Thanks
For every
?found in the query, you must have a parameter inparams=. Order is important, soparams=c(table_x, table_x)should work.