当前位置:首页 > 开发 > 数据库 > 正文

oracle语法备忘-游标

发表于: 2012-12-18   作者:blackproof   来源:转载   浏览:
摘要: oracle的游标备忘   显示游标   declare cursor cur_sel is select t.month_id,t.prov_id from table t where rownum < 100; var_1 table.Month_Id%type; var_2 table.Prov_Id%type; begin open cur_se

oracle的游标备忘

 

显示游标

 

declare
cursor cur_sel is select t.month_id,t.prov_id from table t where rownum < 100;
var_1 table.Month_Id%type;
var_2 table.Prov_Id%type;
begin
open cur_sel;
loop
fetch cur_sel into var_1,var_2;
exit when cur_sel%notfound;
dbms_output.put_line(var_1||' '||var_2);
end loop;
close cur_sel;
end;

 

动态游标

 

declare
type mytype is ref cursor;
mycur mytype;
var_1 table.Month_Id%type;
var_2 table.Prov_Id%type;
begin
open mycur for select t.month_id,t.prov_id from table t where rownum < 100;
loop
fetch mycur into var_1,var_2;
exit when mycur%notfound;
dbms_output.put_line(var_1||' '||var_2);
end loop;
close mycur;
end;

oracle语法备忘-游标

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号