Q:

Write a PL/SQL block to show the uses of a virtual column in an explicit cursor query

0

Write a PL/SQL block to show the uses of a virtual column in an explicit cursor query.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

DECLARE
  CURSOR emp_cur  IS
    SELECT employee_id, first_name,
           (salary * .05) sal_hike
    FROM employees
    WHERE job_id LIKE '%_PROG'
    ORDER BY employee_id;
  emp_sal_rec emp_cur%ROWTYPE;
BEGIN
  OPEN emp_cur;
  LOOP
    FETCH emp_cur INTO emp_sal_rec;
    EXIT WHEN emp_cur%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE (
      'Salary increased for ' || emp_sal_rec.first_name ||
      ' is: ' || emp_sal_rec.sal_hike
    ); 
  END LOOP;
  CLOSE emp_cur;
END;
/

Sample Output:

output

SQL> /
Salary increased for Alexander is: 450
Salary increased for Bruce is: 300
Salary increased for David is: 240
Salary increased for Valli is: 240
Salary increased for Diana is: 210

PL/SQL procedure successfully completed.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now