ref-cursor

Calling a function that returns a refcursor

两盒软妹~` 提交于 2019-11-27 05:55:32
问题 I am using Postgresql 8.3 and have the following simple function that will return a refcursor to the client CREATE OR REPLACE FUNCTION function_1() RETURNS refcursor AS $$ DECLARE ref_cursor REFCURSOR; BEGIN OPEN ref_cursor FOR SELECT * FROM some_table; RETURN (ref_cursor); END; $$ LANGUAGE plpgsql; Now , I can use the following SQL commands to call this function and manipulate the returned cursor ,but the cursor name is automatically generated by the PostgreSQL BEGIN; SELECT function_1(); -

Use text output from a function as new query

[亡魂溺海] 提交于 2019-11-26 23:25:10
问题 In continuing from a previous case that was assisted by @Erwin Brandstetter and @Craig Ringer, I have fixed my code to become as follows. Note, that my function myresult() outputs now text , and not a table (as indeed, as was pointed out in the former case, there is no point in outputting a table object, since we would need to define all its columns ahead, which basically defies the entire purpose): CREATE OR REPLACE FUNCTION myresult(mytable text, myprefix text) RETURNS text AS $func$

What is the equivalent of Oracle’s REF CURSOR in MySQL when using JDBC?

早过忘川 提交于 2019-11-26 23:18:32
问题 In Oracle I can declare a reference cursor... TYPE t_spool IS REF CURSOR RETURN spool%ROWTYPE; ...and use it to pass a cursor as the return value... FUNCTION end_spool RETURN t_spool AS v_spool t_spool; BEGIN COMMIT; OPEN v_spool FOR SELECT * FROM spool WHERE key = g_spool_key ORDER BY seq; RETURN v_spool; END end_spool; ...and then capture it as a result set using JDBC... private Connection conn; private CallableStatement stmt; private OracleResultSet rset; [...clip...] stmt = conn

Error printing REFCURSOR variable as OUT parameter in procedure in Oracle 11g

风流意气都作罢 提交于 2019-11-26 21:58:19
问题 I am using Oracle (Oracle 11.1.0.7.0). I have created a sample stored procedure inside a package MyPackage. I was logged in as a user "DBA_USER" for creating this SP. PROCEDURE WT_MANAGEMENT_PRODUCTIVITY ( cur_output Out T_CURSOR )AS sqlstr VARCHAR2(5000); BEGIN Sqlstr:='select sysdate from dual'; Open cur_output For Sqlstr; END WT_MANAGEMENT_PRODUCTIVITY; I tried to call this SP using var r ref cursor; exec MyPackage.WT_MANAGEMENT_PRODUCTIVITY(:r); print r; But it throws following error in

How to call an Oracle function with a Ref Cursor as Out-parameter from C#?

余生颓废 提交于 2019-11-26 18:29:17
问题 I'm using a product that provides a database API based on Oracle functions and I'm able to call functions via ODP.NET in general. However, I can't figure out, how to call a function that includes a Ref Cursor as Out-parameter. All the samples I found so far either call a procedure with Out-parameter or a function with the Ref Cursor as return value. I tried to define the parameters similiarly, but keep getting the error that the wrong number or type of parameters is supplied. Here is the

How to see refcursor result/output in Oracle SQL Developer? [duplicate]

帅比萌擦擦* 提交于 2019-11-26 18:28:39
问题 Possible Duplicate: Best way/tool to get the results from an oracle package procedure Oracle SQL Developer: Show REFCURSOR Results in Grid? I am new to Oracle SQL Developer. I am using Oracle SQL Developer Version 3.0. I was trying to test my SP using the following query. DECLARE type output_cursor is ref cursor; P_CURSOR output_cursor; BEGIN P_CURSOR := NULL; myPackage.mySPTest ( P_NOTIFICATION_ID => 1975357,P_CURSOR => P_CURSOR) ; END; When I ran the above query in my Oracle SQL Developer,

How to test an Oracle Stored Procedure with RefCursor return type?

烈酒焚心 提交于 2019-11-26 15:39:39
问题 I'm looking for a good explanation on how to test an Oracle stored procedure in SQL Developer or Embarcardero Rapid XE2. Thank you. 回答1: Something like create or replace procedure my_proc( p_rc OUT SYS_REFCURSOR ) as begin open p_rc for select 1 col1 from dual; end; / variable rc refcursor; exec my_proc( :rc ); print rc; will work in SQL*Plus or SQL Developer. I don't have any experience with Embarcardero Rapid XE2 so I have no idea whether it supports SQL*Plus commands like this. 回答2: