Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

PL/SQL ACTIVITIES

Activity 1

1) Declare two additional variables: v_first_name of type VARCHAR2 and size 15, and
v_emp_salary of type NUMBER and size 10.
2) Include an SQL statement that will retrieve the first name and salary of the
employee whose id is 110. Use the variables you declared in number 1 in the
INTO clause of the SQL statement to hold the data you selected from the
database.
3) Print “Hello” followed by the first name of the employee.
4) Calculate the contribution of the employee towards provident fund (PF). PF is 12%
of the basic salary, and the basic salary is 45% of the salary. Use local variables for
the calculation. Try to use only one expression to calculate the PF. Print the
employee’s salary and his or her contribution toward PF.

SET SERVEROUTPUT ON
DECLARE
v_first_name VARCHAR2(15);
v_emp_salary NUMBER(10);
v_pf NUMBER(12,2);
v_basic_salary NUMBER(12,2);
BEGIN
SELECT first_name, salary
INTO v_first_name, v_emp_salary
FROM employees
WHERE employee_id = 110;

v_basic_salary := v_emp_salary * 0.45;


v_pf := v_basic_salary * 0.12;

DBMS_OUTPUT.PUT_LINE('Hello ' || v_first_name);


DBMS_OUTPUT.PUT_LINE('Salary: ' || v_emp_salary);
DBMS_OUTPUT.PUT_LINE('Provident Fund Contribution: ' || v_pf);
END;

You might also like