WRITE A PL/SQL PROGRAM UPDATE THE SALARY BY 15% WORKING IN RESEARCH AND STORE USING CURSOR


--SINGLE QUERY
SELECT * FROM EMP WHERE SAL IN (SELECT * FROM
(SELECT DISTINCT SAL FROM EMP ORDER BY SAL DESC) WHERE ROWNUM<5)


-->UPDATE THE SALARY BY 15% WORKING IN RESEARCH AND STORE
-- THE RESULT IN EMP TABLE AS EMPNO,SYSDATE AND CHANGED SALARY
DECLARE
CURSOR C1 IS SELECT EMPNO FROM EMP,DEPT WHERE emp.deptno=dept.deptno AND DNAME='RESEARCH';
NO INT;
BEGIN
 FOR R IN C1
 LOOP
 NO:=R.EMPNO;
   UPDATE EMP SET SAL=SAL*0.15,hiredate=SYSDATE WHERE EMPNO=NO;
 --  UPDATE EMP SET hiredate=SYSDATE WHERE EMPNO=NO;
 END LOOP;
END;

Previous
Next Post »