Syntax PL - SQL Program
Syntax PL - SQL Program
Declare
<declaration stmts>
Begin
<executable stmts>
[exception <exceptional stmts>]----- optional
End;
PS:
For syntax:
For <var> in <start_num> .. <endnum> loop
<statement(s);>
End loop;
PS:
If <condition> then
<action(s);>
Else
<action(s);>
End if;
If <condition> then
<action(s);>
Elseif <condition> then
<action(s);>
else
<action(s);>
End if;
PS:
Loop syntax:
loop
<statement(s);>
Exit when <condition>;
End loop;
ANSWER:-
declare
n number(20):=123;
s number(13):=0;
d number(3):=1;
r number(3):=10;
begin
d:=mod(n,10);
s:=(s*r)+d;
n:=n/r;
end loop;
end;
/
OUTPUT:-
ANSWER:-
accept number n
declare
isum number(2):=0;
i number;
n number:=&n;
begin
isum:=isum+i;
end loop;
end;
OUTPUT:-
enter the number:7
sum is 28
ANSWER:-
set serveroutput on
declare
area number(5);
rad number(3);
pi number(4):=3.14;
begin
area:=pi*rad*rad;
end loop;
end;
/
OUTPUT:-
area is :27
area is :48
area is :75
area is :108
area is :147