中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 数据库开发 > 数据库综合
关于游标的一点发现
作者:佚名 时间:2004-07-11 10:40 出处:互连网 责编:chinaitpower
              摘要:关于游标的一点发现

  
  昨天在写存储过程的时候发现了一个以前忽视了的地方,不知道对大家有没有用。
  创建显性游标:
  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;
  /
  
  由于使用的游标的不同,我们最终在使用变量的时候还是有一些小区别的。希望大家以后在调代码的时候少走弯路。
  
  
关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有