oracle - SQL exceptions don't appear to be working -
this question has answer here:
anyone know why exceptions aren't working? when test sql exception appears when others.
this first stored procedure, want insert new students using parameter values.
create or replace procedure add_student_to_db (pstuid number, pstuname varchar2) out_of_range exception; begin if pstuid <=1 , pstuid >=499 raise out_of_range; end if; insert student (stuid, stuname) values (pstuid, pstuname); exception when dup_val_on_index dbms_output.put_line('-20010. duplicate student id'); when out_of_range dbms_output.put_line('-20002. student id out of range'); when others dbms_output.put_line('-20000. error'); end;
this second stored procedure, want call first sp.
create or replace procedure add_student_viasqldev (pstuid number, pstuname varchar2) begin insert student (stuid, stuname) values (pstuid, pstuname); dbms_output.put_line('--------------------------------------------'); dbms_output.put_line('adding student id: ' || pstuid || ' name: ' || pstuname); exception when others dbms_output.put_line('-20000. error'); end;
there should exist if pstuid <=1 or pstuid >=499 then
instead of statement out_of_range
Comments
Post a Comment