在一个会话中执行多语句查询 [英] Executing multi - statement query in one session
问题描述
我问过这个问题并想对其进行编辑,但是 StackOverflow 由于某种原因不允许我编辑 .所以这是编辑后的版本
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
例如查询:
create volatile table testTable as (select * from ... blah blah) ;
select top 10 * from testTable ;
drop table testTable ;
它在 sql 辅助中作为一个会话完美执行.我确信可以在一次会话中用 Java 执行它.
It executes perfect in sql assistance as one session. I am sure it is possible to execute it in Java in one session.
目标:需要在一个会话中执行,类似于sql助手
,以便在后续的select语句中可以引用易失性表.来自 select 语句的数据也应该保存在 ResultSet
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我看到了一个关于 mysql 的类似问题的答案.诀窍是打开allow multiple queries
String dbUrl = "jdbc:mysql:///test?allowMultiQueries=true";特别是对于teradata,解决办法是什么?我试过String dbUrl = "jdbc:odbc:dsn?allowMultiQueries=true";
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";
推荐答案
究竟是什么失败了?
是否有错误消息testtable 不存在"?然后您的程序在每次请求后关闭连接.
Is there an error message "testtable doesn't exist"? Then your program closes the connection after each request.
执行 SELECT 时表是否为空?然后您忘记将 ON COMMIT PRESERVE ROWS 添加到 CREATE.
Is the table empty when you do the SELECT? Then you forgot to add ON COMMIT PRESERVE ROWS to the CREATE.
这篇关于在一个会话中执行多语句查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!