zoukankan      html  css  js  c++  java
  • [转]Easy Stored Procedure Output Oracle Select

    本文转自:http://www.oraclealchemist.com/oracle/easy-stored-procedure-output/

    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 DBMS_XMLGEN.GETXML.

  • 相关阅读:
    【LeetCode】面试题59
    【LeetCode】面试题57
    【LeetCode】面试题57
    Chrome查看Markdown并转为PDF
    【LeetCode】232. 用栈实现队列
    【LeetCode】27. 移除元素
    【LeetCode】1323. 6 和 9 组成的最大数字
    【LeetCode】167. 两数之和 II
    第14条:在公有类中使用访问方法而非公有域
    Android Studio项目中三种依赖的添加方式
  • 原文地址:https://www.cnblogs.com/freeliver54/p/3152716.html
Copyright © 2011-2022 走看看