i use R for statistical analysis at work and just set up a R Server with RStudio (or a Server with R would be more correct) i managed to create a connection with RODBC to our Teradata database. So far so good.
Now our administrator would like to add a Queryband with some parameters to our SQL query. That is no problem using SQL directly but does not work with RODBC in R it seems. If i am correct the problem ist that, sqlQuery() always stops after the sep ";" therefore the additional information from the queryband is not send along with the SQl query.
I tried with different versions that normally work e.g. using a multiqueryfunction, but nothing worked I thought maybe parametereized queries could solve this but i couldn't make that work. Any suggestions? Is there maybe a package that can help?
Code: (with db_connection from odbcConnect())
#load package
library(RODBC)
sqlQuery(
db_connection, query =
"SET QUERY_BAND ='USER=MyID;ABT=AS;'
FOR SESSION;
SELECT
*
FROM MyData;
SET QUERY_BAND = NONE FOR SESSION;"
)