You are on page 1of 6

LAB-8

S.Gokul Srinath
19BCE1066

declare
eno1 EMPLO.eno%type:=1;
eno2 EMPLO.eno%type:=2;
esal1 EMPLO.sal%type;
esal2 EMPLO.sal%type;
begin
update EMPLO
set sal=sal+3000
where eno=eno1;
update EMPLO
set sal=sal+2500
where eno=eno2;
select sal into esal1
from EMPLO
where eno=eno1;
select sal into esal2
from EMPLO
where eno=eno2;
dbms_output.put_line('Outside if,original salaries are: '||esal1||' and '||esal2);
if(esal1+esal2>25000) then
update EMPLO
set sal=sal-3000
where eno=eno1;
update EMPLO
set sal=sal-2500
where eno=eno2;
dbms_output.put_line('Inside if,updated salaries are: '||esal1||' and '||esal2);
end if;
end;
/

A2)
declare
x number(1);
y number(1);
begin
for x in 1..5 loop
for y in 1..x loop
dbms_output.put('*');
end loop;
dbms_output.new_line;
end loop;
end;
/

A3)

DECLARE
fact number(10):=1;
i number(2);
n number(2);
BEGIN
n:=&n;
for i in 1..n loop
fact:=fact*i;
end loop;
dbms_output.put_line(n||'!='||fact);
end;
/
A4)

declare
num number(10);
rem number(10);
rev number(10):=0;
begin
num:=#
while num>0 loop
rem:=MOD(num,10);
rev:=(rev*10)+rem;
num:=floor(num/10);
end loop;
dbms_output.put_line('The reverse of the given number is:'||rev);
end;
/
A5)

declare
empno number(2);
name varchar2(50);
basic number(7,2);
gross number(7,2);
begin
empno:=&empno;
name:='&name';
basic:=&basic;
gross:=basic;
if (basic>10000 and basic<20000) then
gross:=gross+(0.10*basic);
elsif(basic>20000 and basic<30000) then
gross:=gross+(0.25*basic);
else
gross:=gross+(0.50*basic);
end if;
dbms_output.put_line('The salary of the employee is '||gross);
end;
/

You might also like