无法执行存储过程

时间:2013-11-06 02:20:04

标签: oracle plsql syntax-error

我正在尝试在主存储过程中执行^存储过程。但它不起作用。

  

错误(11,9):PLS-00103:遇到以下其中一项时遇到符号“FN_UPD”:: =。 (@%;符号“:=”代替“FN_UPD”继续。

代码:

create or replace
procedure FN_READ

is
   cursor C_1 is select distinct(COLUMN1) from TB_SOURCE;
   cursor C_2 is select distinct(COLUMN2) from TB_SOURCE;
   cursor C_3 is select distinct(COLUMN3) from TB_SOURCE;
BEGIN

    for f in C_1
    LOOP
   EXEC FN_UPD('A', 'A');

    end LOOP;


    for f in C_2
    LOOP
   EXEC PROCEDURE FN_UPD(f.COLUMN2, 'M')
    end LOOP;

    for f in C_3
    LOOP
    EXEC FN_UPD(f.COLUMN3, 'O')

    end LOOP;

EXCEPTION
WHEN OTHERS THEN
   raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR-    '||SQLERRM);
END;

2 个答案:

答案 0 :(得分:2)

EXEC(同样适用于EXEC PROCEDURE)在PL / SQL中不起作用,直接使用过程名称:

BEGIN
    FN_UPD('A', 'A');
END;
/

答案 1 :(得分:1)

替换

 EXEC FN_UPD(f.COLUMN3, 'O')

 EXEC PROCEDURE FN_UPD(f.COLUMN2, 'M')

FN_UPD(f.COLUMN3, 'O');

FN_UPD(f.COLUMN2, 'M');

分别

请注意尾随;

所以,你的程序变成了

create or replace
procedure FN_READ

is
   cursor C_1 is select distinct(COLUMN1) from TB_SOURCE;
   cursor C_2 is select distinct(COLUMN2) from TB_SOURCE;
   cursor C_3 is select distinct(COLUMN3) from TB_SOURCE;
BEGIN

    for f in C_1 LOOP
        FN_UPD('A', 'A');
    end LOOP;


    for f in C_2 LOOP
        FN_UPD(f.COLUMN2, 'M')
    end LOOP;

    for f in C_3 LOOP
         FN_UPD(f.COLUMN3, 'O')
    end LOOP;

EXCEPTION
WHEN OTHERS THEN
   raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR-    '||SQLERRM);
END;