How To Write PL/SQL block using TCL

Update the salary of NMR and DJP by 2000 and 1500 than check to see that salary does not exist 20,000.  If total salary is greater than 20,000 than undo the updated salary of NMR and DJP.


    employee

        NO NAME            SAL
---------- -------- ----------
       101 NMR            2000
       102 krishna        1000
       103 rachna         6000
       201 DJP            5000

INPUT
declare
          sum_sal number(10);
begin
          savepoint save;
          insert into employee values(105,'jenny',2000);
          update employee set sal=sal+2000 where name='NMR';
          update employee set sal=sal+1500 where name='DJP';
          select sum(sal) into sum_sal from employee;
                   if sum_sal>20000 then
                   rollback to savepoint save;
                   dbms_output.put_line('salary is not updated');
          else
                   dbms_output.put_line('salary of renuka and mansi is updated!!!!');
          end if;
end;
/



OUTPUT

salary of NMR and DJP is updated!!!!

PL/SQL procedure successfully completed.



Post a Comment

0 Comments