ORA-00922:创建PL / SQL过程时选项丢失或无效

时间:2018-09-10 10:10:12

标签: oracle plsql

获取错误为ORA-00922:创建PL / SQL过程时缺少选项或该选项无效,这是过程。

CREATE OR REPLACE consession_calculate(item_ID IN NUMBER, CON_PRICE OUT NUMBER)
IS 
PRICE NUMBER;
BEGIN
SELECT ITEM_PRICE INTO PRICE FROM ITEM WHERE ITEM_CODE=item_ID;
IF(PRICE<10) THEN
CON_PRICE:=PRICE;
ELSEIF(PRICE>=10 AND PRICE<=100) THEN
CON_PRICE:=(PRICE*10)*100;
ELSE 
CON_PRICE:=(PRICE*20)*100;
END IF;
END;
/

1 个答案:

答案 0 :(得分:2)

您遇到了一些问题:

  • 您缺少PROCEDURE关键字
  • ELSEIF应该是ELSE IF
  • 您不见了,END IF

修改后的代码:

CREATE OR REPLACE PROCEDURE consession_calculate(item_ID IN NUMBER, CON_PRICE OUT NUMBER) IS
    PRICE                                   NUMBER;
BEGIN
    SELECT ITEM_PRICE
      INTO PRICE
      FROM ITEM
     WHERE ITEM_CODE = item_ID;

    IF (PRICE < 10)
    THEN
        CON_PRICE    := PRICE;
    ELSE
        IF (    PRICE >= 10
            AND PRICE <= 100)
        THEN
            CON_PRICE    := (PRICE * 10) * 100;
        ELSE
            CON_PRICE    := (PRICE * 20) * 100;
        END IF;
    END IF;
END;
/

或者,根据 a_horse_with_no_name 注意,您只能添加PROCEDURE并将ELSEIF编辑为ELSIF

CREATE OR REPLACE PROCEDURE consession_calculate(item_ID IN NUMBER, CON_PRICE OUT NUMBER) IS
    PRICE                                   NUMBER;
BEGIN
    SELECT ITEM_PRICE
      INTO PRICE
      FROM ITEM
     WHERE ITEM_CODE = item_ID;

    IF (PRICE < 10)
    THEN
        CON_PRICE    := PRICE;
    ELSIF (    PRICE >= 10
           AND PRICE <= 100)
    THEN
        CON_PRICE    := (PRICE * 10) * 100;
    ELSE
        CON_PRICE    := (PRICE * 20) * 100;
    END IF;
END;
/