O'Reilly logo

Oracle SQL and PL/SQL Handbook: A Guide for Data Administrators, Developers, and Business Analysts by John Adolph Palinski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 15

A1:
declare 
 a number; 
begin 
 a := 10 / 0; 
exception 
 when zero_divide then 
 dbms_output.put_line (‘YOU HAVE ATTEMPTED TO DIVIDE A NUMBER 
                         BY ZERO’); 
end; 
/ 
A2:
declare 
 bad_payroll_number      exception; 
 pragma exception_init (bad_payroll_number,–02291); 
begin 
 insert into tools (fk_payroll_number, tool_name, purchase_date) 
 values (987,‘PLIERS’,‘08-APR-98’); 
exception 
 when bad_payroll_number then 
 dbms_output.put_line (‘You have violated the payroll number constraint’); 
end; 
/ 
A3:
begin 
 insert into emp_tools (fk_payroll_number, tool_name, purchase_date) 
 values (987,‘PLIERS’,‘08-APR-98’); 
exception 
 when others then 
   dbms_output.put_line (‘You have violated the payroll number constraint’); 
end; 
/ 
A4:
 declare lname employee.last_name%type; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required