Monday, February 23, 2009

Exceptional handler In PL-SQL

1 begin
2 delete from dept_college where deptid=10;
3 exception
4 when others then
5 dbms_output.put_line('Connot delete ---foreign key violation');
6* end;
SQL> /

PL/SQL procedure successfully completed.

SQL> select * from dept_college
2 /

DEPTID DEPTNAME LOCATION
--------- --------------- ----------
20 Anil Hyderabad
30 Accounting Banglore
40 Marketing Nagpur
50 Sunil Chennai