The value_error exception is an predefined exception of PL/SQL language and catch numeric or value error. Value_error example declare v_dsp number; begin select description into v_dsp from course where name=’SQL 2′; dbms_output.put_line(‘Description is: ‘||v_dsp); exception when value_error then dbms_output.put_line(‘VALUE_ERROR: ‘||sqlerrm); dbms_output.put_line(‘Change data type of v_dsp in varchar2(2000)’); end; Output: VALUE_ERROR: ORA-06502: PL/SQL: numeric or value…(Continue Reading)
Author: Dev
PL/SQL Others
The others exception is an predefined exception of PL/SQL language and catch any predefined exceptions. Others example 1 declare v_order_id number; begin select order_id into v_order_id from orders where course_id=1234567; dbms_output.put_line(‘Order id is: ‘||v_order_id); exception when others then dbms_output.put_line(‘When others exception error message: ‘||sqlerrm); end; Output: When others exception error message: ORA-01403: no data found…(Continue Reading)
PL/SQL Too_many_rows
The too_many_rows exception is an predefined exception of PL/SQL language. Too_many_rows example 1 declare v_order_id number; begin select order_id into v_order_id from orders where course_id=5; dbms_output.put_line(‘Order id is: ‘||v_order_id); exception when too_many_rows then dbms_output.put_line(‘Tow many rows!’); end; Output: Tow many rows! Too_many_rows example 2 declare v_order_id number; begin select order_id into v_order_id from orders where…(Continue Reading)
PL/SQL No_data_found
The No_data_found exception is an predefined exception of PL/SQL language. No_data_found example 1 declare v_name varchar2(100); begin select first_name into v_name from students where student_id=10000; exception when no_data_found then dbms_output.put_line(‘No student found!’); end; Output: No student found! No_data_found example 2 declare v_name varchar2(100); v_order_id number; begin select name into v_name from course where course_id=2; dbms_output.put_line(‘Course…(Continue Reading)
PL/SQL Exception Handling
In the PL/SQL language the errors are called exceptions. Exceptions can be predefined exceptions (internal error) or user defined exceptions (named by user). Predefined PL/SQL Exceptions The predefined exceptions are internally defined exceptions that have predefined names like no_data_found, too_many_rows, others, invalid_number, zero_divide. The predefined PL/SQL exceptions are declared globally in the package STANDARD and…(Continue Reading)