You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello I am having trouble getting a query when I declare a global temporary table. I can connect to all the other table involved, and I tested the sql query in other software (dbvisualizer) and it runs correctly there.
Database
DB2 v10.5
Here is my code, sorry cannot reproduce
query<-dbSendQuery(conn,
"declare global temporary table session.gtt_test (Test_id BIGINT) ON COMMIT PRESERVE ROWS NOT LOGGED WITH REPLACE; INSERT into session.gtt_test SELECT gtt.id FROM schema.DIM_bank gtt Fetch First 1600 Rows Only; SELECT hey.* FROM session.gtt_test hey Fetch First 50 Rows Only;")
result<-dbFetch(query)
sessionInfo()
I figured it out. Basically you cannot have multiple statements in one dbSendQuery. You can solve the problem by breaking up your query into multiple dbExecute statements before you run your final query to get your data
dbExecute(
edt4p,
"declare global temporary table session.gtt_test (Test_id BIGINT) ON COMMIT PRESERVE ROWS NOT LOGGED WITH REPLACE;")
dbExecute(
edt4p,
"INSERT into session.gtt_test SELECT gtt.id FROM schema.DIM_bank gtt Fetch First 1600 Rows Only;"
)
query<-dbSendQuery(conn,
"SELECT hey.* FROM session.gtt_test hey Fetch First 50 Rows Only;")
result<-dbFetch(query)
sessionInfo()
Issue Description and Expected Result
Hello I am having trouble getting a query when I declare a global temporary table. I can connect to all the other table involved, and I tested the sql query in other software (dbvisualizer) and it runs correctly there.
Database
DB2 v10.5
Here is my code, sorry cannot reproduce
Here is my session info
The text was updated successfully, but these errors were encountered: