PROCEDUREG TO INCREASE THE SALARY OF EMPLOYEE IN ORACLE?



SQL> DECLARE
  2 ECODE EMP.EMPNO%TYPE;
  3 INC_AMOUNT EMP.SAL%TYPE;
  4 PROCEDURE SALARY_IN(ECODE NUMBER, AMOUNT  
  NUMBER) AS
  5 SAL_NULL EXCEPTION;
  6 CURRENT_SAL NUMBER;
  7 BEGIN
  8 SELECT SAL INTO CURRENT_SAL FROM EMP WHERE
  EMPNO=ECODE;
  9 IF CURRENT_SAL IS NOT NULL THEN
 10 UPDATE EMP SET SAL =SAL+AMOUNT WHERE
 EMPNO=ECODE;
 11 DBMS_OUTPUT.PUT_LINE('DATA UPDATED');
 12 ELSE
 13 RAISE SAL_NULL;
 14 END IF;
 15 EXCEPTION
 16 WHEN NO_DATA_FOUND THEN
 17 DBMS_OUTPUT.PUT_LINE('EMPID DOESNOT EXIST');
 18 WHEN SAL_NULL THEN
 19 DBMS_OUTPUT.PUT_LINE('SALARY SHOULD NOT BE
 NULL');
 20 END SALARY_IN;
 21 BEGIN
 22 ECODE:=&ECODE;
 23 INC_AMOUNT:=&INC_AMOUNT;
 24 SALARY_IN(ECODE,INC_AMOUNT);
 25 END;
 26  /

Enter value for ecode: 7499
old  22: ECODE:=&ECODE;
new  22: ECODE:=7499;
Enter value for inc_amount: 500
old  23: INC_AMOUNT:=&INC_AMOUNT;
new  23: INC_AMOUNT:=500;
DATA UPDATED

PL/SQL procedure successfully completed.

SQL> @ INCREMENT.SQL;
Enter value for ecode: 7499
old  22: ECODE:=&ECODE;
new  22: ECODE:=7499;
Enter value for inc_amount: 200
old  23: INC_AMOUNT:=&INC_AMOUNT;
new  23: INC_AMOUNT:=200;
DATA UPDATED

PL/SQL procedure successfully completed.

Comments

Popular posts from this blog

Write a program to add two number using inline function in C++?

Traversing of elements program with algorithm and Flowchart