博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[转]Easy Stored Procedure Output Oracle Select
阅读量:6448 次
发布时间:2019-06-23

本文共 4948 字,大约阅读时间需要 16 分钟。

本文转自:

I answered a question on a DBA Forum today and I thought it was a common enough question to warrant a blog posting.

Question:  I am new to the wonderful world of Oracle. I want to be able to view the results of a stored procedure in an output window, say out of Oracle SQL developer. Unfortunately it appears I need to write some more code to actually view the data.

… 

On a more generic note, can anyone explain to me why Oracle has chosen to make PL/SQL inordinately more complicated than say MS SQL/Servers tSQL? I mean in tSQL I would just write:

CREATE OR REPLACE PROCEDURE TESTSPROC2 AS select * from test_table order by id_no; GO

and viola, a nice result set spits out in Query Analyzer (or a .net application).

Answer:

Before I go on, let me say I agree that PL/SQL is more powerful.  That being said, here are your options.

1. Test it with REFCURSOR using a FUNCTION and selecting from dual:

 

 

2. Use the same function and return it into a variable: 

 

 

3. Use your procedure with a variable:

 

 

#3 is more in-line with your original needs. Personally I’m a fan of #1 and #2 because of the capabilities of returning a refcursor as a function, like passing it into .

 

转载地址:http://mlowo.baihongyu.com/

你可能感兴趣的文章
如何防止网站因改版导致权重下降?
查看>>
《伟大的计算原理》一大数据
查看>>
《UG NX8.0中文版完全自学手册》一导读
查看>>
Windows和Linux端rsync推拉同步时中文乱码解决方法
查看>>
《Spark核心技术与高级应用》——1.3节本章小结
查看>>
解决军哥lnmp一键包报错pycurl.so
查看>>
Google 搜索结果正式 AMP 化
查看>>
《树莓派Python编程入门与实战》——第2章 认识Raspbian Linux发行版 2.1 了解Linux...
查看>>
阿里感悟 (十七)- 计划和规划能力
查看>>
《Java并发编程从入门到精通》显示锁Lock和ReentrantLock
查看>>
《Servlet、JSP和Spring MVC初学指南》——1.12 小结
查看>>
《精通软件性能测试与LoadRunner最佳实战》—第2章2.5节 测试脚本编写
查看>>
《解读NoSQL》——第1章 NoSQL:明智的选择
查看>>
算力即权力
查看>>
《Nmap渗透测试指南》—第6章6.8节目标主机随机排序
查看>>
《Unity 3.x游戏开发实例》——2.8节百分之一的灵感
查看>>
阿里云前端周刊 - 往期回顾(1-3)
查看>>
《Axure RP8 网站和APP原型制作 从入门到精通》一第1章 设计过程概述1.1 设计过程...
查看>>
《嵌入式Linux应用开发完全手册》——1.2 基于ARM处理器的嵌入式Linux系统
查看>>
“数”成金|大数据的正确打开及使用方法
查看>>