获取错误为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;
/
答案 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;
/