Oracle笔记 九、PL/SQL 游标的使用

前端之家收集整理的这篇文章主要介绍了Oracle笔记 九、PL/SQL 游标的使用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<div id="codeSnippetWrapper"> <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 10pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; font-size: 10pt; border-left-style: none; overflow: visible; padding-top: 0px">--演示隐式游标,系统自动声明,自动打开,自动使用并且自动关闭


 emp  sal = 1000;
 || sql%);
;
;
方法:


循环操作
关闭游标*/
     
代码声明了一个游标
 mycur   *  emp  deptno = 20;
 mycur; --打开游标
 mycur  emprow; --把游标所指的纪录放到变量中
   (mycur%notfound); --当游标没有指向行时退出循环
 || emprow.ename ||  || emprow.sal);
 loop;
 mycur;  --关闭游标
;

 mycur   ename,sal  emp  deptno = 30;

 mycur;
 mycur  empname,empsal;
  mycur%notfound;
 || empname ||  || empsal);
 loop;
 c 

 *  dept;
 c;
 c  vDept_row_record;
 c;

 c 

 *  dept;
 c;
 c  vDept_row_record;
 (c%notfound);
 loop;
 c
 c  vDept_row_record;
 (c%) loop
 c  vDept_row_record;
 vDept_row_record  c loop
 loop;
 c(sSal emp.sal%type,sEmpno emp.empno%type)
 *  emp  sal >= sSal  empno > sEmpno;
 record_data  c(2500,6666) loop
 c(sSal emp2.sal%type)
 *  emp2  sal >= sSal  ;
 record_data  c(2500) loop
 (record_data.sal < 3000) 
 emp2  sal = sal + 3    c;

 emp2  sal = sal - 3    c;
 ;
删除和修改
提取的数据行的类型
  ;
;
 (which = ) 
 mycur   *  dept;
 mycur  deptrow;
  (mycur%notfound);
 || deptrow.dname);
 loop;
) 
 mycur   *  emp;
 mycur  emprow;
  (mycur%notfound);
 || emprow.ename);
 loop;
 ;
 mycur;
提取的数据行的类型 ,只能是record或%rowtype类型
 number是错的, emp.ename%type也是错的
    emp%rowtype;
 mycur   *  emp;
 mycur  emprow;
  mycur%notfound;
 || emprow.ename);
 mycur;
;
原文链接:https://www.f2er.com/oracle/72812.html

猜你在找的Oracle相关文章