Skip to content
Advertisement

PL/SQL change value in 1 row in procedure

i do not know where the bug is. I must write the procedure where the 1 specific row will be chaned. Everytime i lunched it, wrote me:

Errors: PROCEDURE RENAME_FLYTICKET Line/Col: 1/65 PLS-00103: Encountered the symbol “(” when expecting one of the following:

:= . ) , @ % default character The symbol “:=” was substituted for “(” to continue.

CREATE OR REPLACE PROCEDURE rename_flyticket (code_ticket INTEGER, new_id varchar2(50)) AS  
 BEGIN  
   UPDATE Flyticket SET id = new_id WHERE flyticketcode = code_ticket;    
COMMIT;  
END; 

Advertisement

Answer

I think that the syntax you want is:

create or replace procedure rename_flyticket (
    p_code_ticket in integer, 
    p_new_id in varchar2
) 
as
begin  
    update flyticket set id = p_new_id where flyticketcode = p_code_ticket;    
    commit;  
end; 
/

The main problem with the original code is that the datatypes do not take length/precision. So VARCHAR2(50) should be just VARCHAR2.

I also added the IN keyword for parameters (that’s the default when not specified, but I find it is better to be explicit about that).

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement