立即执行多个 SQL 语句
这是我的 PL/SQL。
execute immediate '
create table Alex_Test2(col1 varchar2(100));
/
drop table Alex_Test2;
/
';
在动态 SQL 中,创建表然后立即删除。有趣的是,表已成功创建和删除,但我收到错误。
Error starting at line 1 in command:
execute immediate '
Error report:
ORA-06550: line 1, column 17:
PLS-00103: Encountered the symbol "; END;" when expecting one of the following:
:= . ( @ % ;
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
table ALEX_TEST2 created.
table ALEX_TEST2 dropped.
Error starting at line 6 in command:
'
Error report:
Unknown Command
用户实际输入的SQL语句。我无法避免像 ;
和 /
这样的符号。我该如何解决这个问题?或者我怎样才能绕过这个错误?
但是,我仍然需要保留日志。我希望日志只是
table ALEX_TEST2 created.
table ALEX_TEST2 dropped.
谢谢!
Here is my PL/SQL.
execute immediate '
create table Alex_Test2(col1 varchar2(100));
/
drop table Alex_Test2;
/
';
In the dynamic SQL, a table is created and then dropped immediately. The funny thing is that the table is successfully created and dropped but I got error.
Error starting at line 1 in command:
execute immediate '
Error report:
ORA-06550: line 1, column 17:
PLS-00103: Encountered the symbol "; END;" when expecting one of the following:
:= . ( @ % ;
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
table ALEX_TEST2 created.
table ALEX_TEST2 dropped.
Error starting at line 6 in command:
'
Error report:
Unknown Command
The SQL statements actually typed by user. I cannot avoid the symbols like ;
and /
. How can I fixed this problem? Or how can I bypass this error?
However, I still need to keep the log. I expect the log is just
table ALEX_TEST2 created.
table ALEX_TEST2 dropped.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法在执行查询字符串之前对其进行操作?如果你没有能力做到这一点,那么你有能力做什么呢?
听起来您只需要在运行查询字符串之前进行查找和替换即可。
You are unable to manipulate the query string before executing it? If you don't have the ability to do that then what do you have the ability to do?
Sounds like you just need to do a find and replace on the query string before running it.