易截截图软件、单文件、免安装、纯绿色、仅160KB

PL/SQL学习笔记五


游标是从数据库中提取出来的数据,以临时表的形式存放在内存中,在游标中有一个数据指针,在初始状态下指向首记录, 利用fetch语句移动该指针,从而对游标中的数据进行各种操作。
1.定义游标
cursor 游标名 is select语句;
2.打开游标
open 游标名;
3.提取游标数据
fetch 游标名 into 变量名1, 变量名2, ....;

fetch 游标名 into 记录型变量名;
4.关闭游标
close 游标名;
5.游标的属性
%isopen
该属性标识游标是否打开,如果没有打开游标就使用fetch语句将提示错误。
%isfound
该属性标识一个fetch语句是否有值,有值返回true,否则返回false。
%notfound
该属性与%isfound相反。
%rowcount
该属性用于获取游标的数据行数。
示例:
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;
  if mycursor%isopen then
    fetch mycursor into cursorrecord;
    dbms_output.put_line(to_char(cursorrecord.deptno));
    dbms_output.put_line(to_char(mycursor%rowcount));
  else
    dbms_output.put_line('游标还未打开');
  end if;
end;


相关文档:

SQL语句查询是否为空 =null及null

  a                  b                             c&nb ......

C#中操作Oracle时的SQL语句参数的用法

C#中操作Oracle时的SQL语句参数的用法
OracleTransaction myTrans ;
            conn.Open();
            myTrans =conn.BeginTransaction(IsolationLevel.ReadCommitted) ......

SQL时间转换格式

select Convert( varchar(20) , 时间字段 , 格式 ) from 表 如:select Convert(varchar(20),LOGIN_DATE,112) from dbo.C_PARTY_CLIENT 100:Jun 22 2009 12:00AM 101:06/22/2009 102:2009.06.22 103:22/06/2009 104:22.06.2009 105:22-06-2009 106:22
select Convert(varchar(20),<时间字段>,<格式>) f ......

sql日期模糊查询 SQL时间转换格式

Select * from t_user_profile where convert ( varchar ( 21 ),regDate, 120 ) like ' 2008-05-07% ' 表名称:t_user_profile 日期字段名称:regDate
Select   *   from t_user_profile  where  convert(varchar(21),regDate,120) like '2008-05-07%'< ......

Sql server 时间段查询 的相关费解问题

sql server 时间段查询。
==========================================
select g.borrowTime  from t_apartment_goodsborrow g
where g.borrowTime >= '2010-03-11 9:50:43'
2010-03-11 9:52:54
----------------------------------------------------------------------------
select g.borrowTime  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号