Modern College of Engineering, Pune: MCA Department A.Y.2023-24
Modern College of Engineering, Pune: MCA Department A.Y.2023-24
*********************************************************************************************
Q1. Write a PL/SQL block of code that first inserts a record in an ‘emp’ table. Update the salary by Rs. 2000. Then
check to see that the total salary does not exceed 20000. if so, undo the updates made to the salaries.
Ans.:
Query:
DECLARE old_sal
emp.sal%TYPE:=0; temp_sal
emp.sal%TYPE:=0;
BEGIN
END IF;
END;
OUTPUT:
Q2. HRD manager has decided to raise the salary of employees by 0.15. Write a PL/SQL block to accept the employee
number update the salary of that emp. Display message based on the existence of record in employee table.
Ans.:
Query:
emp_name emp.ename%TYPE;
BEGIN
SELECT ename, sal INTO emp_name, old_sal FROM emp WHERE empno = emp_no;
ename, sal INTO emp_name, old_sal FROM emp WHERE empno = emp_no;
END;
OUTPUT:
*****************************************************************************************************
****************************************************************************************************