- 浏览: 1149838 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (411)
- Java Foundation (41)
- AI/机器学习/数据挖掘/模式识别/自然语言处理/信息检索 (2)
- 云计算/NoSQL/数据分析 (11)
- Linux (13)
- Open Source (12)
- J2EE (52)
- Data Structures (4)
- other (10)
- Dev Error (41)
- Ajax/JS/JSP/HTML5 (47)
- Oracle (68)
- FLEX (19)
- Tools (19)
- 设计模式 (4)
- Database (12)
- SQL Server (9)
- 例子程序 (4)
- mysql (2)
- Web Services (4)
- 面试 (8)
- 嵌入式/移动开发 (18)
- 软件工程/UML (15)
- C/C++ (7)
- 架构Architecture/分布式Distributed (1)
最新评论
-
a535114641:
LZ你好, 用了这个方法后子页面里的JS方法就全不能用了呀
页面局部刷新的两种方式:form+iframe 和 ajax -
di1984HIT:
学习了,真不错,做个记号啊
Machine Learning -
赵师傅临死前:
我一台老机器,myeclipse9 + FB3.5 可以正常使 ...
myeclipse 10 安装 flash builder 4.6 -
Wu_Jiang:
触发时间在将来的某个时间 但是第一次触发的时间超出了失效时间, ...
Based on configured schedule, the given trigger will never fire. -
cylove007:
找了好久,顶你
Editable Select 可编辑select
Oracle中Cursor介绍:
http://www.iteye.com/topic/649874
游标小记(收集汇总):
http://www.itpub.net/viewthread.php?tid=897079&highlight=%D3%CE%B1%EA
REF CURSOR:
Oracle REF CURSOR:
http://www.oradev.com/ref_cursor.jsp
Using Ref Cursors To Return Recordsets:
http://www.oracle-base.com/articles/misc/UsingRefCursorsToReturnRecordsets.php
REF CURSOR 小结:
http://www.itpub.net/viewthread.php?tid=443352&highlight=ref%2Bcursor
IS CURSOR DIFFERENT FROM REF CURSOR?
http://forums.oracle.com/forums/thread.jspa?threadID=1086826
REF CURSOR需要显式(explicitly)关闭吗?
http://forums.oracle.com/forums/thread.jspa?threadID=627238
http://searchoracle.techtarget.com/answer/Closing-ref-cursor-after-it-s-used-in-a-Java-program
使用oracle REF CURSOR的例子(scott用户):
关于上面代码中的SYS_REFCURSOR:
查看数据库中打开的游标数:http://www.iteye.com/topic/337796
将 %ROWTYPE 与游标配合使用:
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=/com.ibm.db2.luw.apdv.plsql.doc/doc/c0053880.html
Oracle/PLSQL: Procedure that outputs a dynamic PLSQL cursor:
http://www.techonthenet.com/oracle/questions/cursor1.php
http://www.iteye.com/topic/649874
游标小记(收集汇总):
http://www.itpub.net/viewthread.php?tid=897079&highlight=%D3%CE%B1%EA
REF CURSOR:
Oracle REF CURSOR:
http://www.oradev.com/ref_cursor.jsp
引用
With the REF_CURSOR you can return a recordset/cursor from a stored procedure.
Using Ref Cursors To Return Recordsets:
http://www.oracle-base.com/articles/misc/UsingRefCursorsToReturnRecordsets.php
引用
Since Oracle 7.3 REF CURSORS have been available which allow recordsets to be returned from stored procedures, functions and packages.
REF CURSOR 小结:
http://www.itpub.net/viewthread.php?tid=443352&highlight=ref%2Bcursor
IS CURSOR DIFFERENT FROM REF CURSOR?
http://forums.oracle.com/forums/thread.jspa?threadID=1086826
REF CURSOR需要显式(explicitly)关闭吗?
http://forums.oracle.com/forums/thread.jspa?threadID=627238
引用
Ref cursors otoh are special - as they have no local scope. Only session scope. So as long as that Oracle session exist, that ref cursor created in that session will exist, until explicitly closed. Why? Because ref cursors are intended to be use by the client of that session - which means that irrespective of what happens scope wise on the PL/SQL engine side, that ref cursor handle must "survive" as it can (and often is) used by the client.
This is also the primary cause for cursor leakage. Clients (especially Java apps in my experience) use ref cursors - but forget to close them after use. The open cursor handle count quickly runs up and an ORA error results.. with the Java developers then thinking there is something wrong with Oracle and that the max number of cursor handles per session should be increased.
The oracle's garbage collector does not clean up ref cursor handles - those are only closed either explicitly (you need to code the close) or when the session terminates.
Also, ref cursors are intended for clients to use - not for PL/SQL. So whenever you use a ref cursor in PL/SQL only, you need to ask why. The java/Delphi/C client's ref cursor equivalent in PL/SQL is a DBMS_SQL cursor - that supports a proper call interface, including a describe interface.
Ask The Oracle Expert: Questions & Answers->Closing ref cursor after it's used in a Java program:
This is also the primary cause for cursor leakage. Clients (especially Java apps in my experience) use ref cursors - but forget to close them after use. The open cursor handle count quickly runs up and an ORA error results.. with the Java developers then thinking there is something wrong with Oracle and that the max number of cursor handles per session should be increased.
The oracle's garbage collector does not clean up ref cursor handles - those are only closed either explicitly (you need to code the close) or when the session terminates.
Also, ref cursors are intended for clients to use - not for PL/SQL. So whenever you use a ref cursor in PL/SQL only, you need to ask why. The java/Delphi/C client's ref cursor equivalent in PL/SQL is a DBMS_SQL cursor - that supports a proper call interface, including a describe interface.
http://searchoracle.techtarget.com/answer/Closing-ref-cursor-after-it-s-used-in-a-Java-program
引用
Q:I am sending a variable of ref cursor type to a Java program. Now, how do I close the ref cursor? Does the conn.close in Java close the ref cursors? Is there any way I can explicitly close the same after it is used in Java?
A:With the ref cursor, you're doing everything you need to. That is the way it is done. The caller (your Java program) is responsible for the "close" call -- you don't do that in PL/SQL when the client fetches from the cursor. There's nothing for you to explicitly do any different than you mention.
A:With the ref cursor, you're doing everything you need to. That is the way it is done. The caller (your Java program) is responsible for the "close" call -- you don't do that in PL/SQL when the client fetches from the cursor. There's nothing for you to explicitly do any different than you mention.
使用oracle REF CURSOR的例子(scott用户):
CREATE OR REPLACE PROCEDURE p_refcursor_test ( in_field IN VARCHAR2, in_value IN VARCHAR2, rslt_cur OUT SYS_REFCURSOR ) IS str_sql VARCHAR2(300); TYPE t_EmpRecord IS RECORD( ename emp.ename%TYPE, job emp.job%TYPE, sal emp.sal%TYPE ); v_EmpRecord t_EmpRecord; BEGIN str_sql := 'SELECT ename,job,sal FROM emp '; IF(length(in_field)>0) and (length(in_value)>0) THEN str_sql := str_sql || 'WHERE ' || in_field || ' like ''%' || in_value || '%'''; END IF; dbms_output.put_line(str_sql); --execute immediate str_sql; --动态执行 OPEN rslt_cur FOR str_sql; --如果这个procedure是被java程序调用的(如ibatis中的<procedure>),则这里不可以fetch该rslt_cur,要将下面这个loop循环给注掉!!!否则返回给java ResultSet的结果集将会是空的 LOOP FETCH rslt_cur INTO v_EmpRecord; EXIT WHEN rslt_cur%NOTFOUND; DBMS_OUTPUT.PUT_LINE('名字: ' || v_EmpRecord.ename || ' 工作: ' || v_EmpRecord.job || ' 薪水: ' || v_EmpRecord.sal ); END LOOP; --With the ref cursor, you're doing everything you need to. That is the way it is done. The caller (your Java program) is responsible for the "close" call -- you don't do that in PL/SQL when the client fetches from the cursor EXCEPTION when others then DBMS_OUTPUT.PUT_LINE('------>' ||SQLERRM); END p_refcursor_test;
关于上面代码中的SYS_REFCURSOR:
引用
sys_refcursor是oracle9i以后系统定义的一个refcursor,主要用在过程中返回结果集。 9i之前想要使用ref cursor是要自己定义REF CURSOR类型游标变量的
查看数据库中打开的游标数:http://www.iteye.com/topic/337796
引用
查看游标使用情况:
查看游标执行的sql情况:
select o.sid, osuser, machine, count(*) num_curs from v$open_cursor o, v$session s where user_name = 'user ' and o.sid=s.sid group by o.sid, osuser, machine order by num_curs desc;
查看游标执行的sql情况:
select q.sql_text from v$open_cursor o, v$sql q where q.hashvalue=o.hash_value and o.sid = 123;
将 %ROWTYPE 与游标配合使用:
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=/com.ibm.db2.luw.apdv.plsql.doc/doc/c0053880.html
Oracle/PLSQL: Procedure that outputs a dynamic PLSQL cursor:
http://www.techonthenet.com/oracle/questions/cursor1.php
发表评论
-
Oracle: minus | in | exists
2012-09-05 13:49 1474解释及例子: MINUS Query: http://www. ... -
一个奇怪的Oracle sql问题
2011-01-13 16:13 1365select A.M,B.N from Table1 A ... -
Oracle Analytic Functions:RANK, DENSE_RANK, FIRST and LAST;PARTITION BY
2010-12-13 17:02 1319Oracle/PLSQL: Rank Function: ht ... -
Oracle Analytic Functions:RANK, DENSE_RANK, FIRST and LAST
2010-12-13 17:02 1266Oracle/PLSQL: Rank Function: ht ... -
Oracle:Collections Records Type %TYPE %ROWTYPE
2010-11-09 22:27 1271PL/SQL Collections and Records: ... -
Oracle 锁机制
2010-09-19 20:12 3724Oracle多粒度封锁机制研究: http://www.itp ... -
Oracle Data Dictionary 数据字典
2010-09-19 16:44 1543Oracle数据字典查阅: http://download.o ... -
Oracle Sign Function
2010-09-17 14:52 1466Oracle/PLSQL: Sign Function: ht ... -
Oracle Built-In Functions: Next_Day and Last_Day
2010-09-16 17:09 1540next_day(date,char): 它用来返回从第一个 ... -
Oracle Procedure 存储过程
2010-09-16 08:36 1365Oracle/PLSQL: Creating Procedur ... -
Oracle Exception Handle 异常处理
2010-09-15 13:00 2089Handling PL/SQL Errors: http:// ... -
Oracle 性能工具 : Explain plan、Autotrace、Tkprof
2010-09-14 18:07 2229Oracle: 三个内置的性能工具包 Explain plan ... -
关于Oracle数据和对象的导入导出 [转]
2010-09-14 10:25 1271关于Oracle数据和对象的导入导出 [转]: http:// ... -
Oracle jobs(DBMS_JOB and DBMS_SCHEDULER)
2010-07-21 14:14 7822写PL/SQL procedure的时候,一定要写的够健壮、够 ... -
Oracle 各种注释
2010-07-20 14:19 3651为SQL语句添加注释: http://do ... -
Oracle 监听 本地Net服务名 配置
2010-07-20 10:32 1325Oracle数据库配置: http://shupili1410 ... -
[Oracle]Difference between a database and an instance(数据库 实例 区别)
2010-07-20 09:31 1502Difference between a database a ... -
Oracle Bulk Collect
2010-07-16 10:03 1375On BULK COLLECT: http://www.ora ... -
Oracle/PLSQL: FOR Loop 循环语句
2010-07-15 16:43 9354Oracle/PLSQL: FOR Loop: http:// ... -
Oracle Trigger 触发器
2010-06-09 16:37 1822备忘速查: oracle的update insert dele ...
相关推荐
Oracle游标,或称为光标,是数据库管理系统中用于处理SQL查询的一种机制,它允许程序逐行处理查询结果。在Oracle中,游标是至关重要的,尤其在进行复杂的交互式数据操作时。当一个应用程序尝试打开过多的游标时,...
Oracle 数据库游标的使用方法 Oracle 数据库游标是指在查询返回结果超过一行时,需要使用的显式游标。用户不能使用 select into 语句,而是需要使用游标来处理多行查询结果。在 PL/SQL 中,隐式游标会在查询开始时...
### Oracle中的游标详解 #### 一、引言 在Oracle数据库中,游标是一种非常重要的机制,它允许用户在程序中对查询结果进行逐行处理。游标分为两种主要类型:**隐式游标**和**显示游标**。此外,还可以利用游标进行...
游标(Cursor)是一种机制,它允许我们遍历和操作由SQL查询返回的结果集。通过游标,我们可以控制数据的读取顺序,一次只处理一行,或者在处理完一行后移动到下一行。 2. **游标的属性**: - `%FOUND`:用于检查...
oracle笔记游标的使用,游标的详细代码案例,游标知识点笔记!
Oracle的游标是数据库开发中的一个重要概念,尤其在PL/SQL编程中,游标用于处理SQL查询结果集,使得我们能够逐行处理数据,而不仅仅局限于一次性获取所有数据。在这个主题中,我们将深入探讨游标的定义、类型、使用...
在Oracle数据库中,游标(Cursor)是一种非常重要的编程工具,尤其在处理复杂的数据操作时。游标允许我们逐行处理查询结果,这对于迭代、条件判断或者数据更新等任务非常实用。下面,我们将深入探讨Oracle游标的使用...
Oracle 游标概述 Oracle 游标是 Oracle 数据库中的一种重要概念,用于查询数据库,获取记录集合(结果集)的指针。游标可以看作是一个临时表,你可以对其每一行的数据进行任意的操作。本文将对 Oracle 游标的概念、...
Oracle数据库中的游标是处理查询结果集的一种重要机制,尤其在需要逐行处理多行数据时。游标允许我们按照需要遍历查询结果,并对每一行进行操作。本篇文章将详细解析Oracle数据库中游标的使用方法。 首先,游标分为...
Oracle数据库游标是PL/SQL编程中不可或缺的一部分,它们允许程序逐行处理查询结果,提供了更灵活的数据操作方式。在Oracle数据库中,游标主要分为两种类型:隐式游标和显式游标。 1. **隐式游标**: - 当在PL/SQL...
Oracle游标是数据库编程中非常重要的一个概念,主要用于处理SQL查询的结果集。游标允许我们按需逐行处理数据,而不是一次性加载所有结果。这里详细介绍了Oracle中的三种游标类型:隐式游标、显式游标和REF游标。 1....
Oracle游标是PL/SQL编程中的重要组成部分,主要用于处理单行或多行查询结果。游标允许程序员逐行处理查询结果,而不是一次性加载所有数据。在Oracle中,游标分为显式游标和隐式游标。 1. **隐式游标**:在PL/SQL中...
在Oracle数据库中,游标(Cursor)是处理数据集的一个关键机制,主要用于执行查询并逐行处理结果集。游标可以被视为一个临时存储区,用于保存SELECT语句的结果集,允许程序对这些结果进行迭代访问。 #### 游标的...
Oracle 显式游标和隐式游标 Oracle 中的游标是 SQL 的一个内存工作区,由系统或用户以变量的形式定义。游标有两种类型:显式游标和隐式游标。显式游标是一种明确声明的游标,需要在声明部分使用 CURSOR 语句来定义...
在Oracle数据库中,游标(Cursor)是一种用于检索并处理多行数据的强大工具。它允许用户通过循环逐条处理查询结果集中的每一行数据,这对于需要进行复杂数据处理的应用程序来说非常有用。 #### 二、游标分类 游标...
### Oracle游标使用详解 #### 一、Oracle游标简介 在Oracle数据库中,游标是一种重要的机制,用于处理查询结果集。它允许用户通过PL/SQL编程语言逐行访问和处理查询返回的数据记录。游标可以是显式定义的(即在...
在Oracle数据库中,游标(Cursor)是一种用于处理SQL查询结果集的方式。它允许用户逐行地读取和处理查询结果,这对于需要对每一行数据进行特定操作的情况非常有用。游标可以分为显式游标和隐式游标两种类型。 #### 二...
- 游标(Cursor):它是一个数据库系统中的结构,用于存储执行SQL查询后的结果集信息。游标允许我们遍历结果集,并对每一行进行操作。 - 局部游标和全局游标:局部游标在PL/SQL块中定义,仅在该块的范围内有效;...
Oracle游标是数据库管理系统中的一种数据处理机制,它允许用户按需逐行处理查询结果,而不是一次性加载所有数据。在Java编程中,我们通常通过JDBC(Java Database Connectivity)来与Oracle数据库交互,其中游标扮演...