Write a PL/SQL block to take an input in the form of department number.
If the total salary paid to that department is greater than 1900 then raise the user defined exception, print appropriate message and terminate the block. If the total salary is less than or equal to 1900 update the salaries of the employees working in the department by 2.5%.
DECLARE
NO NUMBER(2);
SUM_SAL NUMBER;
SAL_MORE EXCEPTION;
BEGIN
NO:=&NO;
SELECT SUM(SAL) INTO SUM_SAL FROM EMP WHERE DEPTNO=NO;
IF SUM_SAL>1900 THEN
RAISE SAL_MORE;
ELSE
DBMS_OUTPUT.PUT_LINE('UPDATE THE SALARIES OF THE EMPLOYEES WORKING IN THE DEPARTMENT BY 2.5%');
END IF;
EXCEPTION
WHEN SAL_MORE THEN
DBMS_OUTPUT.PUT_LINE('TOTAL SALARY PAID TO THAT DEPARTMENT IS GREATER THAN 1900.');
END;
/
If the total salary paid to that department is greater than 1900 then raise the user defined exception, print appropriate message and terminate the block. If the total salary is less than or equal to 1900 update the salaries of the employees working in the department by 2.5%.
DECLARE
NO NUMBER(2);
SUM_SAL NUMBER;
SAL_MORE EXCEPTION;
BEGIN
NO:=&NO;
SELECT SUM(SAL) INTO SUM_SAL FROM EMP WHERE DEPTNO=NO;
IF SUM_SAL>1900 THEN
RAISE SAL_MORE;
ELSE
DBMS_OUTPUT.PUT_LINE('UPDATE THE SALARIES OF THE EMPLOYEES WORKING IN THE DEPARTMENT BY 2.5%');
END IF;
EXCEPTION
WHEN SAL_MORE THEN
DBMS_OUTPUT.PUT_LINE('TOTAL SALARY PAID TO THAT DEPARTMENT IS GREATER THAN 1900.');
END;
/
No comments:
Post a Comment