PLSQL 1
PLSQL 1
11. To write PL/SQL program to calculate area of triangle, circle and square using procedure.
SET SERVEROUTPUT ON
DECLARE
l number;
b number;
r number;
h number;
pi float;
squ number;
tri number;
cir number;
as
begin
tri:=0.5*b*h;
dbms_output.put_line('area of triangle:'||tri);
end;
as
begin
pi:=3.14;
cir:=pi*r*r;
dbms_output.put_line('area of circle:'||cir);
end;
as
begin
squ:=l*l;
dbms_output.put_line('area of square:'||squ);
end;
begin
l:=5;
b:=5;
h:=2;
r:=5;
triangle(l,b);
circle(r);
square(h);
end;
OUTPUT:
Area of triangle:25
Area of circle:78.5
Area of square:4
12. To write PL/SQL program to find the factorial of given number using procedure.
SET SERVEROUTPUT ON
declare
n number(2);
p number(5);
i number(2);
begin
n:=&n;
p:=1;
for i in 1..n
loop
p:=p*i;
end loop;
end;
OUTPUT:
ENTER VALUE 5
Program
SQL> create table studres(regno number(4) primary key, name varchar(20), paper1 number(2),
paper2 number(2), paper3 number(2), paper4 number(2));
Table created
SQL> insert into studres values(1001,’mini’, 23, 49, 44, 46);
1 row created
SQL> insert into studres values(1002,’safeer’, 40, 30, 20, 10);
1 row created
SQL> insert into studres values(1003,’baby’, 49, 39, 46, 45);
1 row created
SQL> insert into studres values(1004,’danish’, 40, 10, 20, 22);
1 row created