sys-refcursor

Using ouput parameter of type SYS_refcursor

喜你入骨 提交于 2019-12-24 11:13:34
问题 In my database I have a stored procedure with an OUTPUT parameter of type SYS_REFCURSOR. The application side is wrtitten in C#. Can I assign this procedure's output parameter to a Datatable like: ............. OracleConnection con=new OracleConnection(......); OracleCommand cmd=new OracleCommand("MyStoredProc",con); cmd.CommandType=CommandType.StoredProcedure; cmd.Parameters.Add("REC_CUR",OracleType.Cursor).Direction=ParameterDirection.Output; con.Open(); cmd.ExecuteNonQuery(); DataTable dt=

nPLS-00306: wrong number or types of arguments in call

十年热恋 提交于 2019-12-24 06:46:02
问题 Excuse me if question is being repeated. I have two projects in my solution, a console application and a MVC4 website. I'm using Oracle managed drviers for accessing oracle database 11g. I'm trying to retrieve data from following stored procedure: create or replace procedure "GETEMPIDS" ( p_cursor OUT SYS_REFCURSOR ) is begin OPEN p_cursor FOR select * from EMP; end;​ After making entities and other stuff in my console application, I get data by doing: public List<GETEMPIDS_Result>

Oracle stored procedure error on select

人走茶凉 提交于 2019-12-24 06:39:08
问题 I am getting ORA-06550: line 2, column 1: PLS-00306: wrong number or types of arguments in call to 'GET_EMP_RS' ORA-06550: line 2, column 1: PL/SQL: Statement ignored Error while executing select command stored procedure in oracle. My Procedure is CREATE OR REPLACE PROCEDURE get_emp_rs (p_deptno IN emp.EMPNO%TYPE, p_recordset OUT SYS_REFCURSOR) AS BEGIN OPEN p_recordset FOR SELECT ENAME, JOB, MGR FROM emp WHERE EMPNO = p_deptno ORDER BY ENAME; END; / 回答1: You are not calling the procedure

Returning Oracle ref cursor and appending multiple results

心不动则不痛 提交于 2019-12-23 12:36:35
问题 I have this problem I'm hoping someone knows the answer to. I have an oracle stored procedure that takes a customer id and returns all the customer's orders in a ref_cursor. Oversimplifying it, this is what I have: Orders - orderId - siteID Customers - siteID - Name GetOrder(siteID, outCursor) /* returns all orders for a customer */ Now, I need to write another procedure that takes a customer name and does a LIKE query to get all custIds, then I need to reuse the GetOrder method to return all

How to call a function in a package

邮差的信 提交于 2019-12-22 11:14:16
问题 I'm doing the following but it doesnt work select package_name.function_name(param,param) from dual I'm calling a function that returns a cursor so im guessing "from dual" is the problem is there another way of doing it? 回答1: I presume you mean a Ref Cursor. This is a PL/SQL construct which acts as a pointer to a set of records returned by a query. This means it has to be interpreted by the client which runs the query. For instance, we can map a Ref Cursor to a JDBC or ODBC ResultSet. There

Oracle EXECUTE IMMEDIATE into a cursor

天大地大妈咪最大 提交于 2019-12-19 06:23:09
问题 I have a stored procedure which used the EXECUTE IMMEDIATE command to execute a very long string. How do I support a very long string and return the data into a refcursor? 回答1: Assuming that your SQL is not longer than 32K (as @Tony Andrews hinted at), you should be able to use something like this: declare SQL_Text varchar2(32760) := 'select * from dual'; --your query goes here cur sys_refcursor; begin open cur for SQL_Text; end; When working with Ref Cursors, open-for can be used directly,

how to call one stored proc from anther and modify refcursor that is returned?

早过忘川 提交于 2019-12-18 05:25:08
问题 I have two stored procs, p_proc1 and p_proc2 . p_proc1 returns a refcursor and I want to use the data in p_proc2 . Is it possible call p_proc1 in p_proc2 and modify the dataset (outer join another table)? The database is Oracle. 回答1: Not directly, no. A SYS_REFCURSOR is a pointer to a result-- the only thing you can do with that is to fetch the data. You can't modify the result set. P_PROC2 could fetch the data from the SYS_REFCURSOR, issue queries to get additional data from some other table

Check Values in sys_refcursor

社会主义新天地 提交于 2019-12-13 06:03:45
问题 I have the following code in a function CREATE OR REPLACE FUNCTION my_func ( v_dt events.raised_date%TYPE ) RETURN SYS_REFCURSOR IS p_events SYS_REFCURSOR; OPEN p_events FOR SELECT event_id FROM events WHERE raised_date = v_dt; RETURN p_events; END; I would like to check whether 100 exists in p_events cursor or not. How can I do this inside my function. Any help is highly appreciable. 回答1: It is not good idea to check it inside of the function. You are missing why the cursor is returned.

Returning a cursor from an inner procedure to outer procedure in oracle pl/sql

瘦欲@ 提交于 2019-12-12 13:52:14
问题 I am using oracle PL/SQL procedure. I am calling one procedure inside another. I want to return a cursor from the nested procedure to the outer procedure. Is this possible? How adversely does it affect the procedure? Below is the calling structure: Proc1( data1 IN integer, cursor1 OUT SYS_REFCURSOR ) { Proc2(data2 IN , cursor1 out) { open cursor1 FOR select * from table; } } 回答1: Here is one example of calling procedures that have REF CURSOR OUT parameters. SQL> create or replace procedure p1

Use Oracle Cursor in Proc and Return it?

守給你的承諾、 提交于 2019-12-11 12:49:18
问题 I am working on a package that will return two cursors. One cursor is a list of items with a numeric primary key. The other cursor is a list of files associated with the items Code so far: procedure get_items_with_files( o_results out sys_refcursor, o_files out sys_refcursor ) is begin begin open o_results for select item_id, item_name from items; end; begin open o_files for select item_id item_file_name from item_files if where if.item_id in (select item_id from TABLE(CAST(o_results))); end;