Chinaunix首页 | 论坛 | 博客
  • 博客访问: 735077
  • 博文数量: 803
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 5015
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-28 10:29
文章分类

全部博文(803)

文章存档

2011年(1)

2008年(802)

我的朋友

分类:

2008-10-29 11:49:57


  
  昨天在写过程的时候发现了一个以前忽视了的地方,不知道对大家有没有用。
  创建显性游标:
  create or replace procedure test 
  is 
  cursor test1 is select name from devp;
  test2 devp.name%type;
  begin
  open test1;
  loop
  fetch test1 into test2;
  dbms_output.put_line(test2); --注意,此处用的是test2变量
  exit when test1%notfound;
  end loop; 
  close test1;
  end;
  /
  
  create or replace procedure test 
  is 
  cursor test1 is select name from devp;
  test2 test1%rowtype;
  begin
  open test1;
  loop
  fetch test1 into test2;
  dbms_output.put_line(test2.name); --注意,此处用的是test2.name
  exit when test1%notfound;
  end loop;
  close test1;
  end;
  /
  
  
  下面用隐性游标试一下:
  create or replace procedure test 
  is 
  cursor test1 is select name from devp;
  test2 devp.name%type;
  begin
  for test2 in test1 loop
  dbms_output.put_line(test2.name); --注意,此处用的是test2.name
  end loop;
  end;
  /
  
  create or replace procedure test 
  is 
  cursor test1 is select name from devp;
  test2 test1%rowtype;
  begin
  for test2 in test1 loop
  dbms_output.put_line(test2.name); --注意,此处用的是test2.name
  end loop;
  end;
  /
  
  由于使用的游标的不同,我们最终在使用变量的时候还是有一些小区别的。希望大家以后在调代码的时候少走弯路。
  
  
【责编:admin】

--------------------next---------------------

阅读(446) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~