PL/SQL Cursor Exercises: Fetch the first three rows of a result set into three records using Same explicit cursor into different variables
PL/SQL Cursor: Exercise-26 with Solution
Write a program in PL/SQL to fetch the first three rows of a result set into three records using Same explicit cursor into different variables.
Sample Solution:
Table: employees
employee_id integer first_name varchar(25) last_name varchar(25) email archar(25) phone_number varchar(15) hire_date date job_id varchar(25) salary integer commission_pct decimal(5,2) manager_id integer department_id integerTable: jobs
job_id varchar(25) job_title varchar(50) min_salary integer max_salary integer
PL/SQL Code:
Sample Output:
SQL> / Elizabeth Sales Representative (SA_REP) Harrison Sales Representative (SA_REP) Tayler Sales Representative (SA_REP) PL/SQL procedure successfully completed.
Flowchart:

Improve this sample solution and post your code through Disqus
Previous: Write a program in PL/SQL to show the uses of fetch one record at a time using fetch statement inside the loop.
Next: Write a PL/SQL block to show the uses of a variable in explicit cursor query, and no result set is affected
despite that value of the variable is incremented after every fetch.
What is the difficulty level of this exercise?