Friday 29 June 2012

How To Use If Block In PL/SQL


declare
a varchar2(30);
b varchar2(30);
c number(10);
t number(10,2);
begin
select ename,job,sal into a,b,c from emp where empno=7369;
if b='mgr' then
t:=c+(10/100)*c;
elsif b='president' then
t:=c+(20/100)*c;
elsif b='clerk' then
t:=c+(5/100)*c;
elsif b='peon' then
t:=c+(2/100)*c;
else
t:=0;
end if;
dbms_output.put_line('old sal is'||c);
dbms_output.put_line('new sal is'||t);
dbms_output.put_line('job is'||b);
end;

No comments:

Post a Comment