在线等 oracle 游标不用循环 能否直接取指定行的值? 本帖最后由 lixiaolong09 于 2010-12-13 10:58:14 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 只取一行的数据吗?那就没必要用游标了啊 直接用select into 就好了 办法是有不过通过游标不能实现你可以使用bulk collect 把所有的游标记录放入到一个关联数组里,然后你就直接操作数组就行了。我这里有个例子:SQL> declare 2 type deptrecord is record( 3 deptno dept.deptno%type, 4 dname dept.dname%type, 5 loc dept.loc%type); 6 type number_array is table of deptrecord; 7 number_collection number_array := number_array(); 8 begin 9 number_collection.extend(5); 10 dbms_output.put_line('number_collection的数量:' || 11 number_collection.count); 12 select * bulk collect into number_collection from dept; 13 dbms_output.put_line(number_collection(1).deptno); 14 end; 15 /number_collection的数量:510PL/SQL procedure successfully completedSQL> fetch cursor bulk collect into 数组 求教在一个字符串中查找另一个字符串中子串的集合的高效的方法 to_date()函数格式问题咨询 查询问题,如果查询两个需要汇总的表对比 关于日文oracle中存放中文的问题?? 急!向oracle中clob字段插入数据,insert的时候如何循环? netbeans 连接oracle 相同用户,不同表空间的问题 百万数据性能如何优化 请各位帮忙,在本机如何创建oracle 数据库? 建立触发器出错。各位大虾救命!! oracle数据库如何导出大于某个日期整个库的数据 在线等 菜鸟测试存储过程 如何附值参数 Oracle中的注释导入到sql server2005中
那就没必要用游标了啊 直接用select into 就好了
你可以使用bulk collect 把所有的游标记录放入到一个关联数组里,然后你就直接操作数组就行了。我这里有个例子:SQL> declare
2 type deptrecord is record(
3 deptno dept.deptno%type,
4 dname dept.dname%type,
5 loc dept.loc%type);
6 type number_array is table of deptrecord;
7 number_collection number_array := number_array();
8 begin
9 number_collection.extend(5);
10 dbms_output.put_line('number_collection的数量:' ||
11 number_collection.count);
12 select * bulk collect into number_collection from dept;
13 dbms_output.put_line(number_collection(1).deptno);
14 end;
15 /number_collection的数量:5
10PL/SQL procedure successfully completedSQL>