Create Implicit Cursor - PL/SQL Program

Consider the following tables to complete the following assignment.

Table 1:  'Emp_Detail'

Employee_idFirst_NameLast_nameSalaryDEPT_ID
1ShrutiShrabya500001
2JayaSingh100002
3MangalaThokal600003
4SurendraMaurya700004

Table2: 'Department'

Dept_IDDept_NameManager_ID
1Accounting1
2Shipping3
3Store3

Q. Write a PL/SQL block to create a Implicit cursor using for Loop and show the records of the employees who have a salary greater than 50000.

Answer:

BEGIN
  FOR item IN(SELECT dept_name,d.dept_id,last_name,salary
              FROM department d JOIN emp_detail e
              ON e.dept_id = d.dept_id
              WHERE  salary  > 50000)
    LOOP
      DBMS_OUTPUT.PUT_LINE(item.last_name||' '||item.dept_name
      ||' '||item.dept_id||' '||' '||item.salary);
    END LOOP;
END;


The above code will display the employees who have salary greater than 50000 for selected columns.

Output:

implicit cursor using for loop