using dynamic sql for cursor usage
来源:互联网 发布:服务器安装数据库 编辑:程序博客网 时间:2024/05/21 09:29
在项目有个procedure返回一个cursor变量。 但sql的执行效率很低,于是决定用dynamic sql, 也在网上搜了下, 自己写了个例子。
create or replace procedure emp_select(deptno in number, outCursor out sys_refcursor)
is
v_sql varchar2(500);
begin
v_sql :='select empno, ename,sal from emp where deptno='||deptno;
dbms_output.put_line('SQL IS:'||v_sql);
open outCursor for v_sql;
exception when others then
dbms_output.put_line(sqlerrm);
end;
/
variable p_cursor REFCURSOR;
begin
emp_select(10,:p_cursor);
end;
/
print p_cursor;
在这个例子中说明两个地方:
sys_refcursor:是oracle9i预定义的一个系统cursor.和他对应的用法是在包头中定义,例如:
create or replace type t_emp as object{
empno emp.empno%type,
ename emp.ename%type,
sal emp.sal%type
};
type t_cursor is ref cursor return t_emp;(强引用游标)
type t_cursor if ref cursor;(弱引用游标)
REFCURSOR: ref cursor在sqlplus中的写法。
- using dynamic sql for cursor usage
- Using of REF CURSOR in PL/SQL
- Using Cursor
- SQL support for dynamic schema
- PLSQL Dynamic SQL Using Bind Variat
- [PL/SQL] 用For Loop 替代Cursor
- [PL/SQL] 用For Loop 替代Cursor
- 使用动态SQL语句(Using dynamic SQL),SQLSA,SQLDA
- SQL server Profiler and excution plan usage for CPU usage high analysis
- SQL CURSOR
- Using Process Memory Matrix script for understanding Oracle process memory usage
- sql server游标的Cursor for后面使用变量
- sql server游标的Cursor for后面使用变量
- Usage of Cursor in Oracle Procedure
- EXECUTE IMMEDIATE option for Dynamic SQL and PL/SQL
- SQL Server使用触发器删除重复的列(Delete duplicate rows using cursor in SQL Server)
- Retrieve multiple Oracle Ref Cursor using .NET data Provider for Oracle
- Retrieve multiple Oracle Ref Cursor using .NET data Provider for Oracle
- 377本O'Reilly英文原版电子书下载分享
- 至理名言
- solaris JAVA Desktop
- base64编码
- C# 创建快捷方式,如建立桌面和程序夹的快捷方式链接,并且上ALL USERS级别
- using dynamic sql for cursor usage
- 实战LSMW(07)
- 游戏反汇编 武林走路call
- Google Loses Its China Boss (from businessweek.com)
- MySQL安装 Apply security settings报错1045解决方案
- POJ 1017 模拟啊模拟
- 李开复辞职前后的故事
- 用户 'sa' 登录失败。原因: 未与信任 SQL Server 连接 的解决方法SQL Server 连接相关联。
- 关于FTP client下载进度条的开发与实现思路