执行存储过程时出错

时间:2013-10-01 12:55:47

标签: oracle

在执行下面的存储过程时,我在Oracle中遇到错误。能不能让我知道错误是什么。

[Error] Syntax check (5: 22): ERROR line 5, col 22, ending_line 5, ending_col 22, Found 'TABLE', Expecting: ;   -or-   :=   -or-   .   -or-   @   -or-   (  ROW

PROCEDURE MyProcedure(res OUT NUMBER)
 AS
      is_output    BOOLEAN;
BEGIN
 TRUNCATE TABLE MyTable;

END MyProcedure;

1 个答案:

答案 0 :(得分:4)

TRUNCATE是一个DDL语句,因此从pl / sql调用它时需要使用EXECUTE IMMEDIATE

PROCEDURE MyProcedure(res OUT NUMBER)
AS
    is_output    BOOLEAN;
BEGIN

    EXECUTE IMMEDIATE 'TRUNCATE TABLE MyTable';

END MyProcedure;