一、匿名遊標sql
begin for c_row in (select futu_exch_type, futucode_type from hs_user.fucontractmodel where futu_exch_type = 'F3') loop DBMS_OUTPUT.PUT_LINE(c_row.futu_exch_type||c_row.futucode_type); end loop; end; /
二、顯示遊標oop
declare cursor c_fucontractmodel is select futu_exch_type, futucode_type from hs_user.fucontractmodel where futu_exch_type = 'F3'; c_row c_fucontractmodel%rowtype; begin for c_row in c_fucontractmodel loop DBMS_OUTPUT.PUT_LINE(c_row.futu_exch_type||c_row.futucode_type); end loop; end; /
三、顯示打開與fetch循環fetch
declare cursor c_fucontractmodel is select futu_exch_type, futucode_type from hs_user.fucontractmodel where futu_exch_type = 'F3'; c_row c_fucontractmodel%rowtype; begin open c_fucontractmodel; loop fetch c_fucontractmodel into c_row; exit when c_fucontractmodel%NOTFOUND; DBMS_OUTPUT.PUT_LINE(c_row.futu_exch_type||c_row.futucode_type); end loop; close c_fucontractmodel; end; /
四、跳出循環code
set serveroutput on; declare v_iLoop int; v_jLoop int; begin for v_iLoop in 1..3 loop v_jLoop := 0; for v_jLoop in 1..10 loop dbms_output.put_line(v_jLoop); if v_jLoop = 5 then exit; end if; end loop; end loop; end; /