Executing multi - statement query in one session

半城伤御伤魂 提交于 2019-12-10 12:05:16

问题


I have asked this question and wanted to edit it , however StackOverflow for some reason did not allow me to edit . So here is the edited version


For example a query :

           create volatile table testTable as (select * from ... blah blah) ;
           select top 10 * from testTable  ;
           drop table testTable ;

It executes perfect in sql assistance as one session. I am sure it is possible to execute it in Java in one session.

Goal : need to execute it in one session similar to sql assistant so that it is possible to refer to the volatile table in the subsequent select statement. Also the data from the select statement should be saved in the ResultSet


PS I saw one answer to a similar question about mysql. The trick is to turn on allow multiple queries String dbUrl = "jdbc:mysql:///test?allowMultiQueries=true"; For teradata specifically, what is the solution ? I tried String dbUrl = "jdbc:odbc:dsn?allowMultiQueries=true";


回答1:


What is exactly failing?

Is there an error message "testtable doesn't exist"? Then your program closes the connection after each request.

Is the table empty when you do the SELECT? Then you forgot to add ON COMMIT PRESERVE ROWS to the CREATE.



来源:https://stackoverflow.com/questions/21605803/executing-multi-statement-query-in-one-session

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!