用这种方式报如下错误:CREATE GLOBAL TEMPORARY TABLE TEMP_TAB1(
table_name VARCHAR2(20),
primary_key VARCHAR2(100),
field VARCHAR2(1000))
ON COMMIT PRESERVE ROWS;Error: PLS-00103: 出现符号 "CREATE"在需要下列之一时:
begin case declare exit
for goto if loop mod null pragma raise return select update
while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge
<a single-quoted SQL string> pipe
table_name VARCHAR2(20),
primary_key VARCHAR2(100),
field VARCHAR2(1000))
ON COMMIT PRESERVE ROWS;Error: PLS-00103: 出现符号 "CREATE"在需要下列之一时:
begin case declare exit
for goto if loop mod null pragma raise return select update
while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge
<a single-quoted SQL string> pipe
...
execute immediate 'create global TEMPORARY TABLE TEMP_TAB1( ...';
...不过我觉得动态创建临时表没有必要
在外面创建就可以了
不过你都这么确定的表结构了,为什么要用动态SQL?
CREATE GLOBAL TEMPORARY TABLE TEMP_TAB1(
table_name VARCHAR2(20),
primary_key VARCHAR2(100),
field VARCHAR2(1000))
ON COMMIT PRESERVE ROWS;
在数据库里面建好这个表;过程里面直接使用就TEMP_TAB1就OK过程里面执行 DDL 很慢,没有必要,还只能用动态sql