practical no:20
case statement
SQL> set serveroutput on;
SQL> declare
2 grade char(1):='A';
3 begin
4 case grade
5 when 'A'then dbms_output.put_line('Excellent');
6 when 'B'then dbms_output.put_line('very good');
7 when 'C'then dbms_output.put_line('good');
8 when 'D'then dbms_output.put_line('average');
9 when 'F'then dbms_output.put_line('passed with grace');
10 else dbms_output.put_line('failed');
11 end case;
12 end;
13 /
Excellent
PL/SQL procedure successfully completed.
continue
SQL> set serveroutput on;
SQL> declare
2 a number(2);
3 begin
4 for a in 10..20 loop
5 if(a=15) then
6 continue;
7 end if;
8 dbms_output.put_line('value of a:'||a);
9 end loop;
10 end;
11 /
value of a:10
value of a:11
value of a:12
value of a:13
value of a:14
value of a:16
value of a:17
value of a:18
value of a:19
value of a:20
PL/SQL procedure successfully completed.
goto
SQL> set serveroutput on;
SQL> declare
2 a number(2):=20;
3 begin
4 <<loopstart>>
5 while a < 30 loop
6 dbms_output.put_line('value of a:'||a);
7 a:=a+1;
8 if a=30 then
9 a:=a+1;
10 goto loopstart;
11 end if;
12 end loop;
13 end;
14 /
value of a:20
value of a:21
value of a:22
value of a:23
value of a:24
value of a:25
value of a:26
value of a:27
value of a:28
value of a:29
PL/SQL procedure successfully completed.