当我在 Oracle shell 中运行以下命令时,它工作正常
truncate table table_name
但是当我尝试将其放入存储过程时
CREATE OR REPLACE PROCEDURE test IS
BEGIN
truncate table table_name;
END test;
/
它失败了
ERROR line 3, col 14, ending_line 3, ending_col 18, Found 'table', Expecting: @ ROW or ( or . or ; :=
Why?
Oracle PL/SQL 中的所有 DDL 语句都应在语句前使用 Execute Immediate。因此你应该使用:
execute immediate 'truncate table schema.tablename';
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)