1

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

错误(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;
4

2 回答 2

2

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

BEGIN
    FN_UPD('A', 'A');
END;
/
于 2013-11-06T02:21:52.323 回答
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;
于 2013-11-06T06:07:53.583 回答