0% found this document useful (0 votes)
16 views3 pages

14 Prac (DBMS)

Nice

Uploaded by

jeanque750
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

14 Prac (DBMS)

Nice

Uploaded by

jeanque750
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Goto statement Q.

Divide by zero

SQL> declare QL> declare

2 begin 2 N number;

3 dbms_output.put_line('code start'); 3 begin

4 dbms_output.put_line('before goto 4 N:=10/0;


statement');
5 Exception when zero_divide then
5 goto down;
6 dbms_output.put_line('Devide by zero
6 dbms_output.put_line('statement will not occures');
get executed');
7 End;
7 <<down>>
8 /
8 dbms_output.put_line('the flow of
execution'); Devide by zero occures

9 End;

10 / PL/SQL procedure successfully completed.

code start

before goto statement

the flow of execution

PL/SQL procedure successfully completed.


Practical 14

Execrise 1.

2. SQL> declare

QL> declare 2 ex exception;

2 a number:=&a; 3 a number;

3 b number; 4 begin

4 begin 5 a:=&a;

5 b:=a/0; 6 if a>100 then

6 exception 7 raise ex;

7 when zero_divide then 8 else

8 dbms_output.put_line('Devide by zero'); 9 dbms_output.put_line(a||'hi');

9 end; 10 end if;

10 / 11 exception

Enter value for a: 5 12 when ex then

old 2: a number:=&a; 13 dbms_output.put_line('a is greater than


100');
new 2: a number:=5;
14 end;
Devide by zero
15 /

Enter value for a: 150


PL/SQL procedure successfully completed.
old 5: a:=&a;

new 5: a:=150;

a is greater than 100

PL/SQL procedure successfully completed.


SQL> declare

2 vdno customers.id%type;

3 child_found Exception;

4 pragma exception_init(child_found,-02292);

5 begin

6 vdno:=&id;

7 delete from customers where id=vdno;

8 exception

9 when child_found then

10 dbms_output.put_line('child record found');

11 end;

12 /

Enter value for id: 1

old 6: vdno:=&id;

new 6: vdno:=1;

PL/SQL procedure successfully completed.

You might also like