Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable in UPDATE oracle in procedure : invalid identifier

I don't understand why service is complaining with Fehler(36,11): PL/SQL: ORA-00904: "FOUND_VP": invalid identifier

Variable is declared in the first begin... Is it not possible to use variable directly in queries ?

when trying store following procedure :

create or replace PROCEDURE fpwl_update_vp(
     my_zn IN NUMBER, my_verwaltung IN VARCHAR2 , my_variante IN NUMBER, my_vp IN NUMBER 
   ) IS



BEGIN

DECLARE
search_VP IFT_INFO_LAUF.VP%TYPE;
found_VP IFT_INFO_LAUF.VP%TYPE;
INFOversion number := 25;


BEGIN -- search SYFA_VP

          SELECT SYFA_VP
          INTO found_VP
          FROM FPWL_VP_MAPPING
          WHERE INFO_VP=search_VP ;


          exception
          when no_data_found then
           dbms_output.put_line ('Kein SYFA VP : Importiere aus SYFA');
          --found_VP:=:=cus_info25.pa_info_data.fn_insert_syfa_vp(my_vp,25);

          WHEN OTHERS THEN
          ROLLBACK;
          RETURN;
END; -- SYFA VP


-- Update VP
UPDATE IFT_INFO_LAUF
 SET vp = found_VP
WHERE id_kopf IN 
  (SELECT id_kopf 
    FROM ift_info_kopf 
    WHERE fahrtnummer= my_zn  
    AND verwaltung= my_verwaltung
    AND variante = my_variante
  )
;


  --COMMIT;
    EXCEPTION
    WHEN OTHERS THEN
        ROLLBACK;

END ;
like image 973
OpenStove Avatar asked Jan 28 '26 01:01

OpenStove


1 Answers

Your problem is that found_VP is going out of scope.

Move the contents of the "DECLARE" block to just after the "IS":

create or replace PROCEDURE fpwl_update_vp(
 my_zn IN NUMBER, my_verwaltung IN VARCHAR2 , my_variante IN NUMBER, my_vp IN NUMBER 
) IS
  search_VP IFT_INFO_LAUF.VP%TYPE;
  found_VP IFT_INFO_LAUF.VP%TYPE;
  INFOversion number := 25;
BEGIN
  BEGIN -- search SYFA_VP

  etc
like image 90
Colin 't Hart Avatar answered Jan 31 '26 06:01

Colin 't Hart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!