cursor _
Define the cursor: cursor cursor name is select statement:
Open cursor: open cursor name
Fetch cursor: fetch cursor name into variable name
Close the cursor: close cursor name
declare
cursor cur_1 is
select tid,title from logtypes ; --------- cursor declaration
v_time logtypes.time% type;
v_title logtypes.title%type; --------- Define the data variable in the receiving cursor
v_typercd cur_1%rowtype ; -------- Accept data by record
begin
open cur_1; ------- open the cursor
loop
fetch cur_1 into v_tid, v_title ; ------ Fetch the data in the cursor and traverse the next row of data in the cursor
exit when cur_1%notfound ; ------- check if the last line has been reached
dbms_output.put_line(' Read tid='||v_tid||' title='||v_title); -------- Output the data in the cursor
end loop;
close cur_1; -------- close the cursor
open cur_1; ------- open the cursor
loop
fetch cur_1 into v_typercd ;
exit when cur_1%notfound ;
dbms_output.put_line('--//读取tid='||v_typercd.tid||' title='||v_typercd.title);
end loop;
close cur_1; ------ close the cursor
-----for loop cursor
for tmp_record in cur_1 loop
dbms_output.put_line('++//读取tid='||tmp_record.tid||' title='||tmp_record.title);
end loop;
end;