PL/SQL - Explicit Cursors

Explicit cursor

Explicit cursors are programmer defined cursors with more control over the context area. The explicit cursor should be defined in the declaration section of the PL/SQL block.

Below are the steps for defining explicit cursors.

  • Declaring the cursor.
  • Opening the cursor.
  • Fetching the cursor.
  • Closing the cursor.

create procedure proc_test_stk as cursor main_cur is select stock_code from stock_master;

cur_parameters main_cur%rowtype;

begin open main_cur; loop fetch main_cur into cur_parameters; exit when main_cur%notfound;

insert into test_stk (stock_name) select cur_parameters.stock_code from dual;

end loop; close main_cur; end;

/

exec proc_test_stk;

select * from test_stk;

/ SELECT GREATEST (1, ‘3.925’, ‘2.4’) “Greatest” FROM DUAL;

/ create table test_stk ( stock_name varchar2(100) );


Read More