I have the following function in R
:
dbhandle <- odbcDriverConnect('driver={SQL Server};
server=myServer;database=myDB;
trusted_connection=true')
func <- function(x){
sqlQuery(dbhandle, 'select attr from myTable where cond = x')
}
I want to know how to pass the x
parameter to the where
condition for the cond
attribute. For example, I want to calculate func(10)
, then the query must be:
select attr from myTable where cond = 10