Q:

Write a program in PL/SQL to create an implicit cursor with for loop

0

Write a program in PL/SQL to create an implicit cursor with for loop.

All Answers

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

BEGIN
    FOR emprec IN(SELECT department_name,
                       d.department_id,
					   first_name,
                       last_name,
                       job_id,
                       salary
                FROM   departments d
                       join employees e
                         ON e.department_id = d.department_id
                WHERE  job_id = 'ST_CLERK'
                       AND salary > 3000) LOOP
        dbms_output.Put_line('Name: '
		                     ||emprec.first_name
                             ||' '
							 ||emprec.last_name||chr(9)
							 ||' Department: '
                             ||emprec.department_name||chr(9)
                             ||' Department ID: '
                             ||emprec.department_id||chr(9)
                             ||' Job ID: '
                             ||emprec.job_id||chr(9)
                             ||' Salary: '
                             ||emprec.salary);
    END LOOP;
END; 
/

Sample Output:

SQL> /
Name: Julia Nayer        Department: Shipping    Department ID: 50       Job ID: ST_CLERK        Salary: 3200
Name: Laura Bissot       Department: Shipping    Department ID: 50       Job ID: ST_CLERK        Salary: 3300
Name: Jason Mallin       Department: Shipping    Department ID: 50       Job ID: ST_CLERK        Salary: 3300
Name: Curtis Davies      Department: Shipping    Department ID: 50       Job ID: ST_CLERK        Salary: 3100
Name: Stephen Stiles     Department: Shipping    Department ID: 50       Job ID: ST_CLERK        Salary: 3200
Name: Trenna Rajs        Department: Shipping    Department ID: 50       Job ID: ST_CLERK        Salary: 3500
Name: Renske Ladwig      Department: Shipping    Department ID: 50       Job ID: ST_CLERK        Salary: 3600

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