简体   繁体   中英

Passing multiple argument to dbGetQuery()?

I am using ROracle package to fetch records from database. I need to pass multiple values from dbGetQuery() , so that I can use them in where clause of query. Suppose I have:

 query <- "select abc from tablename where value1= (:1)

Then I can get the table data by calling

data <- dbGetQuery(connection, query, condition1 ). 

I will get the data in data variable. The problem I am facing is if I have to pass multiple values from dbGetQuery() then how to do it.

Example:

query <- "select abc from tablename where value1= (:1) and value1=(:2)

now if I call

data <- dbGetQuery(connection, query, condition1, condition2)

it will give error.

I tried passing a vector but still i am getting error, like

data <- dbGetQuery(connection, query, c("condition1", "condition2"))

Is there a way I can do it?

Something like this should work:

data <- dbGetQuery(connection, query, 
                   list=as.list(c("condition1", "condition2")))

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM