易截截图软件、单文件、免安装、纯绿色、仅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;


相关文档:

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

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

SQL Server数据库维护计划的实施步骤(转帖)

 我公司在组建局域网时,考虑到商业企业的特点,仔细考量了购、销、存三大环节中发生的各种数据及其存储问题后,选定了以Windows 2000 Server为操作系统,SQL Server 2000为数据库平台来搭建局域网的应用系统的软件平台,以网线为载体将购、销、存等核心部门的计算机通过局域网平台紧密地连接起来。这样,各个核心部门每天 ......

SQL Server常用函数

在数据库查询数据时,我们经常使用一些函数,使我们的查询更加方便快捷,下面就把SQL Server中我们常用的几个函数给列举出来,供参考。
1.字符串函数用户控制返回给用户的字符串,这些功能仅用于字符型数据。
2.日期函数用于操作日期值,我们不能直接对日期运用数学函数。
3.数学函数用于对数值进行代数运算。
4.系统函 ......

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号