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

oracle Cursor使用大全

使用Cursor:
--测试一下,今天才申请使用itpub.net 的blog
declare
RoomID Room.RoomID%Type;
RoomName Room.RoomName%Type;
cursor crRoom is
select RoomID,RoomName
from Room;
begin
open crRoom;loop;
fetch crRoom into RoomID,RoomName;
exit when crRoom%notFound;
end loop;
close crRoom;
end;
 
3.1在游标使用入口参数
在SQL语句的Where 子句中恰当使用 相关语句简化逻辑,本来需要使用两个游标,把相关入口参数放入到SQL语句的Where 子句中,一个就搞定了:
cursor crRoom is
select
distinct 楼层,房屋用途
from TT_没有处理的房屋 t
where 数据级别>= 0 and 房屋处理类别= 3 and 产权编号=p_产权编号
and 拆迁房屋类别=p_拆迁房屋类别
and 面积>0 and (not p_房屋用途 is null
and 房屋用途=p_房屋用途
or p_房屋用途 is null);
另外一个例子:
CREATE OR REPLACE PROCEDURE PrintStudents(
p_Major IN students.major%TYPE) AS
CURSOR c_Students IS
SELECT first_name, last_name
from students
WHERE major = p_Major;
BEGIN
FOR v_StudentRec IN c_Students LOOP
DBMS_OUTPUT.PUT_LINE(v_StudentRec.first_name || ' ' ||
v_StudentRec.last_name);
END LOOP;
END;
 
Oracle带的例子examp6.sql
DECLARE CURSOR bin_cur(part_number NUMBER) IS SELECT amt_in_bin
from bins
WHERE part_num = part_number AND
amt_in_bin > 0 ORDER BY bin_num
FOR UPDATE OF amt_in_bin;
bin_amt bins.amt_in_bin%TYPE;
total_so_far NUMBER(5) := 0;
amount_needed CONSTANT NUMBER(5) := 1000;
bins_looked_at NUMBER(3) := 0;
BEGIN
OPEN bin_cur(5469);
WHILE total_so_far < amount_needed LOOP
FETCH bin_cur INTO bin_amt;
EXIT WHEN bin_cur%NOTFOUND;
/* If we exit, there's not enough to *
* satisfy the order. */ bins_looked_at := bins_looked_at + 1;
IF total_so_far + bin_amt < amount_needed THEN
UPDATE bins SET amt_in_bin = 0 WHERE CURRENT OF bin_cur;
-- take everything in the bin total_so_far := total_so_far + bin_amt;
ELSE -- we finally have enough UPDATE bins SET amt_in_bin = amt_in_bin
- (amount_needed - total_so_far)
WHERE CURRENT OF bin_cur;
total_so_far := amount_needed;
END IF;
END L


相关文档:

Oracle外部表小例

1)建立操作系统目录e:\test,准备数据文件dept.txt并置于e:\test之下
"10","ACCOUNTING","NEW
YORK"
"20","RESEARCH","DALLAS"
"30","SALES","CHICAGO"
"40","OPERATIONS","BOSTON"
2)创 ......

oracle management server(oms)启动问题

 
      配置一个管理资料库,启动:Configuration and Migration tools/Enterprise Manager Configuration Assistant。在配置操作中选择配置本地的oracle management server/创建一个新的资料库档案/典型。系统将会创建一个名为oemrep的数据库,保存管理信息,其中你需要指定sys和system帐 ......

Oracle 分区表

Oracle 分区表
Oracle提供了分区技术以支持VLDB(Very Large DataBase)。分区表通过对分区列的判断,把分区列不同的记录,放到不同的分区中。分区完全对应用透明。
Oracle的分区表可以包括多个分区,每个分区都是一个独立的段(SEGMENT),可以存放到不同的表空间中。查询时可以通过查询表来访问各个分区中的数据,也可以 ......

甲骨文推出Oracle PeopleSoft Enterprise 9.1

为了帮助企业提高员工效力,甲骨文公司日前在2009甲骨文全球大会上推出最新版Oracle PeopleSoft Enterprise管理软件,即PeopleSoft Enterprise人力资本管理9.1、PeopleSoft Enterprise PeopleTools 8.50、PeopleSoft Enterprise学习管理9.1和PeopleSoft Enterprise门户9.1。  这个吸收了来自150多个客户的反馈信息 而开发 ......

oracle用户权限的查询

oracle中查看用户权限
1.查看所有用户:
  select * from dba_users;
  select * from all_users;
  select * from user_users;
2.查看用户或角色系统权限(直接赋值给用户或角色的系统权限):
  select * from dba_sys_privs;
  select * from user_sys_privs;
3.查看角色(只能查看登陆用 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号