vendredi 27 avril 2018

How to use if_else with sql query in RODBC package R

I am using the RODBC package in R to run a SQL query. I'd like to add a simple condition to run this query. I am able to get results from the below query

library(RODBC)
database1 <- odbcConnect(dsn = "<database_name>")
sqlQuery(database1, "SELECT * FROM TABLE")

But when I add an ifelse() statement to it, then it doesn't work

ifelse(1<2, sqlQuery(database1, "SELECT * FROM TABLE"), "")

What really went wrong here?

Unfortunately, I cannot produce a reproducible example as the question needs a database connection.

Thanks!

Aucun commentaire:

Enregistrer un commentaire