Sunday, 9 June 2013

PL/SQL program to update a table

Create table emp29(name varchar2(22),startdate date,salary number(33),flag number(22));

Inserting values in the table:

Insert into emp29 values('abc','1-mar-99',4000,1);
Insert into emp29 values('ac','1-mar-99',40040,0);
Insert into emp29 values('bc','1-mar-99',1000,1);


PL/SQL block:

DECLARE
date_compare date;
date_ofjoin date;
BEGIN
date_compare:='&date_compare';
if(to_char(date_ofjoin) < to_char(date_compare)) then
update emp29
set salary=salary+(salary*0.15);
else
update emp29 set salary=salary+(salary*0.5) ;
end if;
END;

No comments:

Post a Comment