I am using the amazing glue_sql to write complex queries and I love it.
However, I was not able to figure out how to loop over subqueries.
For instance something like:
table1 <- glue_sql("SELECT * FROM realtable_one", .con = oracon)
table2 <- glue_sql("SELECT * FROM realtable_two", .con = oracon)
mytables <- c('table1', 'table2')
purrr::map(mytables, glue_sql("SELECT * FROM ({.}), .con = oracon)
even a gool ol loop does not work, such as:
for(tab in mytables){dbGetQuery(oracon,
glue_sql("SELECT * FROM ({tab}), .con = oracon))}
This syntax does not work but I cant understand why... Any ideas? Thanks!