oracle游标的使用及属性.docxVIP

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
oracle游标的使用及属性

oracle游标的使用及属性oracle游标的使用游标是从数据表中提取出来的数据,以临时表的形式存放到内存中,在游标中有一个数据指针,在初始状态下指向的是首记录,利用fetch语句可以移动该指针,从而对游标中的数据进行各种操作, 然后将操作结果写回到数据库中。一:定义游标 cursor  游标名  is  select  语句;示例: set  serveroutput on  declare  tempsal scott.emp.sal%type; cursor mycursor is  select  * from scott.emp where sal > tempsal; begin tempsal :=800; open mycursor; end;二:打开游标 语法结构:  open 游标名 打开游标分为两步: 1  将符合条件的记录送入内存  2 将指针指向第一条记录三:提取游标数据 语法形式: fetch  游标名 into 变量名1,变量名2,.....; 或者 fetch  游标名 into 记录型变量名; 示例: set serveroutput on  declare  tempsal scott.emp.sal%type; cursor mycursor is select * from scott.emp where sal > tempsal; cursorrecord mycursor%rowtype; begin tempsal :=800; open mycursor; fetch mycursor into cursorrecord; dbms_output.put_line(to_char(cursorrecord.deptno)); end;四:关闭游标 close 游标名;Oracle游标的属性之一------%isopen%isopen 属性----测试游标是否打开,没打开的情况下使用fetch语句将提示错误。示例: set serveroutput on declare tempsal scott.emp.sal%type; cursor mycursor is select * from scott.emp where sal tempsal ; cursorrecord mycursor%rowtype; begin tempsal := 800; if mycursor%isopen then dbms_output.putline(to_char(cursorrecord.deptno); else dbms_output.put_line(游标没有打开); end if; end;Oracle游标的属性之二------%found该属性是测试前一个fetch语句是否有值,有值将返回true ,不然false.示例: set serveroutpu on declare tempsal scott.emp.sal%type; cursor mycursor is select * from scott.emp where sal tempsal; cursorrecord mycursor%rowtype; begin tempsal := 800; open mycursor; fetch mycursor into cursorrecord; if mycursor%found then dbms_output.put_line(to_char(cursorrecord.deptno); else dbms_outpu.put_line(没有数据); end if; end;Oracle游标的属性之三------%notfound该属性是%found属性的反逻辑,常被用于退出循环。set serveroutput ondeclare tempsal scott.emp.sal%type; cursor mycursor is select * from scott.emp where sal tempsal; cursorrecord mycursor%rowtype;begin tempsal :=800; open mycursor; fetch mycursor into cursorrecord; if mycursor%notfound then dbms_output.put_line(to_char(cursorrecord.deptno); else dbms_output.put_line(发现数据); end if; end;?/smh821025/article/details/3043203%notfound的理解文档中的解释:It re

文档评论(0)

hagoulz + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档