2013-04-12 5 views
0

Je reçois une erreur avec un proc que j'ai créé. Le corps de proc est: -Erreur lors de la création de la procédure

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; 
/

Les erreurs sont les suivantes: -

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 

Répondre

0

Je vois des erreurs mais pas celles que vous avez déclaré:

SELECT sysdate INTO v_curr_date FROM dual; 

v_curr_date est un paramètre d'entrée et ne peut pas être utilisé comme cible de SELECT ou 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 est un type, pas une variable de curseur.

v_comment := ... 

v_comment n'est pas déclaré. Essayez de corriger ces problèmes et voyez si les choses s'améliorent.

Partagez et appréciez.

+0

Je ne reçois pas de telles erreurs. J'ai rapporté toutes les erreurs que je reçois. –

+0

Quelle version d'Oracle utilisez-vous? Lorsque j'ai compilé votre procédure sous Oracle 11.1, elle a souligné les problèmes que j'ai mentionnés dans mon message. Une dernière chose que je viens de remarquer - vous avez écrit 'IF NULL = v_curr_date' pour déterminer si v_curr_date contient NULL. Cela peut compiler mais ne fera probablement pas ce que vous vouliez. Vous voudrez peut-être envisager de réécrire ceci comme «IF v_curr_date IS NULL». –

Questions connexes