plsql - 从参考游标返回值到客户端
问题描述
将 ref 游标返回给客户端意味着什么以及如何将 ref 游标值传递给 oracle 中的其他程序。请帮帮我。
提前致谢
解决方案
好的,下面是在 sqlplus 中返回 ref 游标的过程、函数和匿名块的示例:
ops$tkyte@ORA817DEV.US.ORACLE.COM> create or replace package types
2 as
3 type rc is ref cursor;
4 end;
5 /
包创建。
ops$tkyte@ORA817DEV.US.ORACLE.COM>
ops$tkyte@ORA817DEV.US.ORACLE.COM>
ops$tkyte@ORA817DEV.US.ORACLE.COM> create or replace procedure get_cursor_proc( p_cursor in out types.rc )
2 is
3 begin
4 open p_cursor for select * from dual;
5 end;
6 /
程序已创建。
ops$tkyte@ORA817DEV.US.ORACLE.COM>
ops$tkyte@ORA817DEV.US.ORACLE.COM> create or replace function get_cursor_func return types.rc
2 as
3 l_cursor types.rc;
4 begin
5 open l_cursor for select * from dual;
6 return l_cursor;
7 end;
8 /
创建的函数。
ops$tkyte@ORA817DEV.US.ORACLE.COM>
ops$tkyte@ORA817DEV.US.ORACLE.COM>
ops$tkyte@ORA817DEV.US.ORACLE.COM> variable x refcursor
ops$tkyte@ORA817DEV.US.ORACLE.COM> set autoprint on
ops$tkyte@ORA817DEV.US.ORACLE.COM>
ops$tkyte@ORA817DEV.US.ORACLE.COM> REM procedure
ops$tkyte@ORA817DEV.US.ORACLE.COM> exec get_cursor_proc(:x)
PL/SQL 过程成功完成。
D
X
ops$tkyte@ORA817DEV.US.ORACLE.COM>
ops$tkyte@ORA817DEV.US.ORACLE.COM> REM function
ops$tkyte@ORA817DEV.US.ORACLE.COM> exec :x := get_cursor_func
PL/SQL 过程成功完成。
D
X
ops$tkyte@ORA817DEV.US.ORACLE.COM>
ops$tkyte@ORA817DEV.US.ORACLE.COM> REM anonymous block
ops$tkyte@ORA817DEV.US.ORACLE.COM> begin
2 open :x for select * from dual;
3 end;
4 /
PL/SQL 过程成功完成。
D
X
推荐阅读
- mathjax - 我怎样才能中断变量名?
- python - 如何预测 Keras 中每个序列的多个值?LSTM 层
- iframe - 第三方重定向在 iframe 内的 Samesite Lax 预期行为
- c - 立即复制宏中的文本
- javascript - 两个手风琴,但仅使用 Javascript 为第一个箭头设置动画
- c++ - 为什么下面这段代码返回的是指针指向的值而不是指针的地址?
- c++ - 从 GUI 文件资源管理器执行程序,并且不生成终端
- c++ - 有没有办法使用 VFW 将压缩的视频数据写入缓冲区而不是文件?
- xcode - _shouldMakeReadyForDevelopment 检查失败,即使设备没有被密码锁定
- javascript - 使用 cts.fieldValueMatch 搜索 dateTime 数据类型的通配符