0

这是我的 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.

谢谢!

4

1 回答 1

2

您无法在执行查询字符串之前对其进行操作?如果你没有这个能力,那你有什么能力去做?

听起来您只需要在运行查询字符串之前对其进行查找和替换。

于 2011-11-14T23:36:45.083 回答