0

我创建的 proc 出现了一些错误。proc主体是:-

CREATE OR REPLACE PROCEDURE suppress_termination_charge(v_curr_date IN DATE)
IS

TYPE suppress_term_cust_type IS RECORD (id NUMBER(11),pev NUMBER(11),piv NUMBER(11));
TYPE cur_suppress_term_cust IS REF CURSOR RETURN suppress_term_cust_type;
v_count NUMBER(4);
v_serv_item suppress_term_cust_type;
v_serv_itm_pev service_item.price_excluding_vat%TYPE;
v_serv_itm_piv service_item.price_including_vat%TYPE;

BEGIN

v_count:=0;

IF NULL=v_curr_date THEN
    SELECT sysdate INTO v_curr_date FROM dual;
END IF;

OPEN cur_suppress_term_cust FOR
    SELECT id AS id,price_excluding_vat AS pev,price_including_vat AS piv  FROM service_items;

LOOP 
FETCH cur_suppress_term_cust INTO v_serv_item;
EXIT WHEN cur_suppress_term_cust%NOTFOUND;

    v_comment := 'Price changed from ('||v_serv_item.pev||', '||v_serv_item.piv||') to (0,0) (PEV, PIV) on '||v_curr_date||' for managed cease';

    UPDATE service_items
    SET price_including_vat=0, price_excluding_vat=0 , comments= v_comment
    WHERE id = v_serv_item.id;

    v_count:=v_count+1;

    IF v_count=5000 THEN
        COMMIT;
        v_count:=0;
    END IF;

END LOOP;

CLOSE cur_suppress_term_cust;

END;
/

错误如下:-

SQL> SHOW ERROR;
Errors for PROCEDURE SUPPRESS_TERMINATION_CHARGE:
LINE/COL ERROR
-------- -----------------------------------------------------------------
19/30    PLS-00103: Encountered the symbol "IS" when expecting one of the
         following:
         . ( % ; for

23/2     PLS-00103: Encountered the symbol "FETCH" when expecting one of
         the following:
         constant exception <an identifier>
         <a double-quoted delimited-identifier> table LONG_ double ref
         char time timestamp interval date binary national character
         nchar


LINE/COL ERROR
-------- -----------------------------------------------------------------
41/2     PLS-00103: Encountered the symbol "CLOSE" when expecting one of
         the following:
         end not pragma final instantiable order overriding static
         member constructor map
4

1 回答 1

0

我看到了错误,但没有看到您报告的错误:

    SELECT sysdate INTO v_curr_date FROM dual;

v_curr_date是输入参数,不能用作 SELECT 或 FETCH 的目标。

    OPEN cur_suppress_term_cust FOR...
    FETCH cur_suppress_term_cust INTO v_serv_item;
    EXIT WHEN cur_suppress_term_cust%NOTFOUND.

cur_suppress_term_cust是 TYPE,而不是游标变量。

    v_comment := ...

v_comment未声明。

尝试解决这些问题,看看情况是否有所改善。

分享和享受。

于 2013-04-12T11:02:31.580 回答