触发器创建时PLS-00103 sqlplus错误

时间:2014-11-07 19:23:09

标签: sql sqlplus

我尝试在Oracle sqlplus上编译此代码,但它返回了一些错误。 我做错了什么?

CREATE OR REPLACE TRIGGER check_id
BEFORE INSERT ON Area
FOR EACH ROW
DECLARE
numero AREA.codigo%TYPE;

BEGIN   
    SELECT MAX(CODIGO) INTO numero FROM AREA;
    IF numero < 42
        :NEW.codigo := 42;
    ELSE 
        :NEW.codigo := numero +1;
    END IF;
END;
/

SQL&GT;显示错误;

Errors for TRIGGER CHECK_ID:

LINE/COL ERROR
-------- -----------------------------------------------------------------
7/3      PLS-00103: Encountered the symbol "" when expecting one of the
         following:
         * & - + / at mod lembrete rem then <um expoente (**)> e ou ||
         multiset

1 个答案:

答案 0 :(得分:0)

您在

行上缺少关键字THEN
    IF numero < 42

应该是

    IF numero < 42 THEN