in PL/SQL by
Explain what Is A Cursor For Loop And How Does It Differ From An Explicit Cursor?

1 Answer

0 votes

Cursor FOR loop is a shortcut to use explicit cursors. It does not require explicit opening, fetching, and closing of the cursor. In other words, the cursor FOR loop implicitly opens the cursor, fetches the record, and closes the cursor. In the cursor FOR loop, the cursor is defined and its attributes are checked within the processing of the FOR loop. The records are also implicitly defined within the loop, as shown in the following code:


v_increment number(10.2); 

Cursor em P_cursor IS 

Select emp_code. emp_name. emp_salary from t_employeeS; 


FOR emp_record IN em p_cursor 

v_increment emp_record.emp_salary • 0.20 


(emp_FREOFthent_COOR 11 'Ilemp_record.emp_name II " II v_increment); 



It is also possible to use a cursor FOR loop with a subquery, where the cursor name is not defined. In this case, the attributes of the cursor cannot be checked as no explicit cursor name is defined.

Related questions

0 votes
asked Mar 13 in PL/SQL by rajeshsharma
0 votes
asked Mar 8 in PL/SQL by sharadyadav1986