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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -