OUT parameter of type REF CURSOR
DB: Oracle Database 10g Release 10.2.0.3.0 - Production
OS: Windows xp
I have got these two types:
TYPE myrecord IS RECORD
(column1 tab1.col1%TYPE,
column2 tab1.col2%TYPE
TYPE my_ref_cur IS REF CURSOR RETURN myrecord;Then I have this procedure:
PROCEDURE proc1 (pid IN NUMBER, pout1 OUT my_ref_cur);How can I call the procedure from a pl/sql block and fetch from the cursor variable?
I tried this, but it does not work for me:
DECLARE
lid NUMBER := 748;
lcur1 my_ref_cur
begin
proc1 (lid, lcur1);
end;I receive the error Wrong number or types of arguments in call to 'proc1'
How it must be called?
Thanks
seems to work
SQL> create table tab1
2 (col1 number
3 ,col2 number
4 );
Table created.
SQL> insert into tab1 values (1,1);
1 row created.
SQL> commit;
Commit complete.
SQL>
SQL> create or replace package pack
2 is
3 TYPE myrecord IS RECORD
4 (column1 tab1.col1%TYPE,
5 column2 tab1.col2%TYPE
6 );
7 TYPE my_ref_cur IS REF CURSOR RETURN myrecord;
8 procedure proc1 (pid IN number
9 , pout1 OUT my_ref_cur);
10 end pack;
11 /
Package created.
SQL>
SQL> show error
No errors.
SQL>
SQL> create or replace
2 package body pack
3 is
4 procedure proc1 (pid IN number
5 , pout1 OUT my_ref_cur
6 )
7 is
8 begin
9 open pout1
10 for select col1
11 , col2
12 from tab1;
13 end proc1;
14 end pack;
15 /
Package body created.
SQL> show error
No errors.
SQL>
SQL> DECLARE
2 lid NUMBER := 748;
3 lcur1 pack.my_ref_cur;
4 r tab1%rowtype;
5 begin
6 pack.proc1 (lid, lcur1);
7 fetch lcur1 into r;
8 dbms_output.put_line (r.col1||' - '||r.col2);
9 close lcur1;
10 end;
11 /
1 - 1
PL/SQL procedure successfully completed.
Similar Messages
-
I have two packages (please see below). A procedure from the first package (TEST1) calls a procedure in the second package (TEST2), which has an output parameter of REF CURSOR TYPE.
I am getting an error at compile time, in the calling procedure.
Can anyone please help on finding out what am I missing here?
Thank you in advance.
- Ketan Bhuptani
Here are the procedures:
(1)
CREATE OR REPLACE PACKAGE TEST1
AS
TYPE cursor_type_pass IS REF CURSOR;
PROCEDURE call_cursor (result_flag OUT varchar2);
END TEST1;
CREATE OR REPLACE PACKAGE BODY TEST1
AS
PROCEDURE call_cursor (result_flag OUT varchar2) IS
v_salary int;
proc_cursor cursor_type_pass;
CURSOR emp_cur is select empid from emp;
BEGIN
FOR emp_cur_var IN emp_cur
LOOP
test2.open_cursor(emp_cur_var.empid, proc_cursor);
v_salary := proc_cursor.salary;
-- getting an error Invalid reference to variable proc_cursor at this line
END LOOP;
END call_cursor;
END TEST1;
(2)
CREATE OR REPLACE PACKAGE TEST2
AS
TYPE cursor_type_return IS REF CURSOR;
PROCEDURE open_cursor (emp_id IN varchar2, out_cur OUT cursor_type_return);
END TEST2;
CREATE OR REPLACE PACKAGE BODY TEST2
AS
PROCEDURE open_cursor (emp_id IN varchar2, out_cur OUT cursor_type_return) IS
BEGIN
OPEN out_cur FOR
select location, salary from emp_information where empid = emp_id;
END open_cursor;
END TEST2;
create table emp_information
(location varchar2(30), salary int, empid varchar2(10));
create table emp
(empid varchar2(10));Your scenario is not very clear to me, but let us do some test coding here, see if it helps you,SQL> create or replace package test_pkg1 as
2 TYPE cursor_type1 IS REF CURSOR;
3 procedure proc1;
4 end;
5 /
Package created.
SQL> create or replace package test_pkg2 as
2 TYPE cursor_type2 IS REF CURSOR;
3 procedure proc2(pCur IN OUT cursor_type2);
4 end;
5 /
Package created.
SQL> create or replace package body test_pkg2 as
2 procedure proc2(pCur IN OUT cursor_type2) is
3 begin
4 open pCur for SELECT ename from my_emp;
5 end;
6 end;
7 /
Package body created.
SQL> create or replace package body test_pkg1 as
2 procedure proc1 is
3 vRefCur cursor_type1;
4 vEname VARCHAR2(20);
5 vRefCur2 test_pkg2.cursor_type2;
6 begin
7 test_pkg2.proc2(vRefCur); -- this is possible, but I do not like it.
8 vRefCur2 := vRefCur; -- you can also do this, but you have no reason to do this
9 loop
10 fetch vRefCur2 into vEname;
11 exit when vRefCur2%NOTFOUND;
12 dbms_output.put_line(vEname);
13 end loop;
14 close vRefCur2;
15 end;
16 end;
17 /
Package body created.
SQL> exec test_pkg1.proc1;
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
JAMES
FORD
MILLER
PL/SQL procedure successfully completed.
Let us make it simple,
SQL> create or replace package body test_pkg1 as
2 procedure proc1 is
3 vRefCur cursor_type1;
4 vEname VARCHAR2(20);
5 --vRefCur2 test_pkg2.cursor_type2;
6 begin
7 test_pkg2.proc2(vRefCur);
8 --vRefCur2 := vRefCur;
9 loop
10 fetch vRefCur into vEname;
11 exit when vRefCur%NOTFOUND;
12 dbms_output.put_line(vEname);
13 end loop;
14 close vRefCur;
15 end;
16 end;
17 /
Package body created.
SQL> exec test_pkg1.proc1;
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
JAMES
FORD
MILLER
PL/SQL procedure successfully completed.You can play with it number of different ways.
Let me know what questions and we will take it from there.
Thx,
SriDHAR -
Read parameter with type ref to
Hi,
I am implementing BADI "HRPAYFR_N4DS_CUST". In this, in one of the method there is a parameter (importing) "IO_N4DS_DAQ" type ref to "IF_HRPAYFR_N4DS_DAQ".
Can you please let me know how to read PROCESS_EMPLOYEE-IO_EMPL -> CONSTRUCTOR-IV_PERNR value.
Thanks,
SatishHi Sathish,
In BADI implementation try to get the PERNR like
LV_PERNR = IO_N4DS_DAQ->MO_EMPL->MV_PERNR. -
hi
i have a stored procedure which accepts deptno and returns the employees from emp as an out parameter of type ref cursor.
if i wish to see that in forms how can i get it?
pls suggest me or if anyone has tried it kindly help with the code
regards
premYou base your block on the procedure instead of a table.
Check "Query Data Source Type" under Database in the Property Palette
for the block. You can select "Procedure".
Then, in "Query Data Source Name" you specify <Package.Procedure>.
(Alternatively you can also fill the block from a trigger by calling the procedure)
The note 66887.1 in Metalink is an excellent cookbook. -
Passing Ref Cursor as parameter to object type method
I am encountering a problem passing a parameter of type REF CURSOR to methods of a set of object types I am developing.
Here is an example of what I am trying to do:
create or replace package p1 as
type c_Cursor is ref cursor;
end p1;
create or replace type t_Object as object
not instantiable method m1(p_Cursor in p1.c_Cursor) return varchar2
) not instantiable not final;
create or replace type t_Subtype under t_Object as
overriding method m1(p_Cursor in p1.c_Cursor)
return varchar2
The problem is that the PL/SQL compiler gives the error message PLS-00201 "p1.c_Cursor" not defined.
According to my PL/SQL book (SF's Oracle PL/SQL Programming) the only way to use a ref cursor as a parameter to functions/procedures is to wrap them in a package. Indeed I have developed a test procedure in a different package that uses p1.c_Cursor as a parameter and it works fine.
Oracle's documemtation suggests that object security (roles etc) can cause this error but as all the objects are being created in the same schema I don't see how this should be a problem.
If anyone can suggest how to get around this problem I will be very grateful.
BTW, if there are any mistakes in my sample code it's because I am writing it from memory as I don't have Internet access at work.
Thanks,
Charles.Thanks for your reply. I am still baffled as to why it doesn't work but, as you correctly point out, SYS_REFCURSOR works just fine. I figured that out earlier today and now the problem is solved.
Charles. -
How return parameter ref Cursor from procedure using dynamic SQL?
I sorry, but i very need help.
I using Oracle 8.0.6
I need to return parameter of type ref Cursor from procedure.
create or replace package PlanExp is
type cursortype is ref cursor;
procedure ShowPlan (cursorparam out
cursortype.............);
end PlanExp;
create or replace package body PlanExp is
procedure ShowPlan (cursorparam out cursortype,
.............) Is
sql_str varchar2(1000);
sql_str_select varchar2(100);
sql_str_from varchar2(100);
sql_str_where varchar2(500);
Return_Code integer;
Num_Rows integer;
cur_id_sel integer;
tSum_Plan DBMS_SQL.NUMBER_TABLE;
tSum_Plan_Ch DBMS_SQL.NUMBER_TABLE;
tSum_Plan_Day DBMS_SQL.NUMBER_TABLE;
begin
/* calculating string variables ........... /*
sql_str := 'select ' || sql_str_select ||
'from ' || sql_str_from ||
'where ' || sql_str_where ||
'group by ' || sql_str_select;
cur_id_sel := dbms_sql.open_cursor;
dbms_sql.parse(cur_id_sel, sql_str, dbms_sql.native);
dbms_sql.define_array(cur_id_sel, 1, tSum_Plan, 20, 1);
dbms_sql.define_array(cur_id_sel, 2, tSum_Plan_Ch, 20, 1);
dbms_sql.define_array(cur_id_sel, 3, tSum_Plan_Day, 20, 1);
Return_Code := dbms_sql.execute(cur_id_sel);
delete from TEMP_SHOWPLAN;
Loop
Num_Rows := dbms_sql.Fetch_Rows(cur_id_sel);
dbms_sql.column_value(cur_id_sel, 1, tSum_Plan);
dbms_sql.column_value(cur_id_sel, 2, tSum_Plan_Ch);
dbms_sql.column_value(cur_id_sel, 3, tSum_Plan_Day);
if Num_Rows = 0 then
exit;
end if;
Exit When Num_Rows < 20;
End Loop;
dbms_sql.close_cursor(cur_id_sel);
end;
end PlanExp;
How return cursor (cursorparam) from 3 dbms_sql.column_value-s ?I am using Oracle 8.1.7, so I don't know if this will work in
8.0.6 or not:
SQL> CREATE TABLE test
2 (col1 NUMBER,
3 col2 NUMBER,
4 col3 NUMBER)
5 /
Table created.
SQL> INSERT INTO test
2 VALUES (1,1,1)
3 /
1 row created.
SQL> INSERT INTO test
2 VALUES (2,2,2)
3 /
1 row created.
SQL> INSERT INTO test
2 VALUES (3,3,3)
3 /
1 row created.
SQL> CREATE TABLE temp_showplan
2 (tSum_Plan NUMBER,
3 tSum_Plan_Ch NUMBER,
4 tSum_Plan_Day NUMBER)
5 /
Table created.
SQL> EDIT planexp
CREATE OR REPLACE PACKAGE PlanExp
IS
TYPE CursorType IS REF CURSOR;
PROCEDURE ShowPlan
(cursorparam IN OUT CursorType,
sql_str_select IN VARCHAR2,
sql_str_from IN VARCHAR2,
sql_str_where IN VARCHAR2);
END PlanExp;
CREATE OR REPLACE PACKAGE BODY PlanExp
IS
PROCEDURE ShowPlan
(cursorparam IN OUT CursorType,
sql_str_select IN VARCHAR2,
sql_str_from IN VARCHAR2,
sql_str_where IN VARCHAR2)
IS
sql_str VARCHAR2 (1000);
cur_id_sel INTEGER;
return_code INTEGER;
BEGIN
DELETE FROM temp_showplan;
sql_str := 'INSERT INTO temp_showplan '
|| ' SELECT ' || sql_str_select
|| ' FROM ' || sql_str_from
|| ' WHERE ' || sql_str_where;
cur_id_sel := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE (cur_id_sel, sql_str, DBMS_SQL.NATIVE);
return_code := DBMS_SQL.EXECUTE (cur_id_sel);
DBMS_SQL.CLOSE_CURSOR (cur_id_sel);
OPEN cursorparam FOR SELECT * FROM temp_showplan;
END ShowPlan;
END PlanExp;
SQL> START planexp
Package created.
Package body created.
SQL> VARIABLE g_ref REFCURSOR
SQL> EXEC PlanExp.ShowPlan (:g_ref, 'col1, col2,
col3', 'test', ' 1 = 1 ')
PL/SQL procedure successfully completed.
SQL> PRINT g_ref
TSUM_PLAN TSUM_PLAN_CH TSUM_PLAN_DAY
1 1 1
2 2 2
3 3 3 -
Is it possible to identify records in ref cursor without actually fetching
CREATE OR REPLACE PROCEDURE test_miles (p_ref_cursor OUT SYS_REFCURSOR)
IS
BEGIN
OPEN p_ref_cursor FOR
select 5168 mem_uid, 16353 bac_uid, '2013-JAN-19' dte,3 no_of_pax,'AnoopM' username,NULL reward_id from dual
union select 4702 mem_uid , 16344 bac_uid, '2013-JAN-29' dte, 2 no_of_pax,'RAZO' username, NULL reward_id from dual;
END;
Hi all,
I have having a Procedure with out parameter as a REF CURSOR.
This ref cursor will be returned to the calling service.
Is there a way in oracle by which we can identify whether the Ref cursor holds data without actually fetching it.
Since if i choose to fetch the data, i will lose one row when i return the ref cursor back to the calling service. Or else is there way i can retrieve the row i lose during fetch.
Other alternative what have been suggested is create and object type ,fetch the ref cursor values in object type. Then i can use the ref cursor to return the data by table casting.
one more solution is
OPEN
FETCH
CLOSE
OPEN (AGAIN)
In reality the select statement will have is huge lines of code therefore want a suggestion whether there is an alternative to the above solution
Please suggest.CREATE OR REPLACE PROCEDURE test_miles (p_ref_cursor OUT SYS_REFCURSOR)
IS
BEGIN
OPEN p_ref_cursor for SELECT * from DUAL;
OPEN p_ref_cursor FOR
select 5168 mem_uid, 16353 bac_uid, '2013-JAN-19' dte,3 no_of_pax,'AnoopM' username,NULL reward_id from dual
union select 4702 mem_uid , 16344 bac_uid, '2013-JAN-29' dte, 2 no_of_pax,'RAZO' username, NULL reward_id from dual;
END;
If the second cursor doesnt fetch any data then an empty dataset will be stored -
Invalid SQL error using REF CURSOR
I'm getting an "invalid SQL statement" in my function that is returning a REF CURSOR. I have tested this function in SQL*Plus and it works fine.
-- package level variable
TYPE t_cursor IS REF CURSOR;
Function find_patient
p_ssan IN varchar2,
p_patient_details OUT t_cursor
RETURN t_cursor
IS
v_cursor t_cursor;
BEGIN
OPEN v_cursor FOR
SELECT name,sex,pay_grade,
FLOOR(MONTHS_BETWEEN(sysdate,birthdate) / 12) AS age,
patient_num
FROM patient
WHERE ssan = p_ssan;
p_patient_details := v_cursor;
RETURN p_patient_details;
END find_patient;
-- C# code
OracleParameter ssan_in = new OracleParameter("p_ssan",OracleDbType.Varchar2);
OracleParameter cursor_out = new OracleParameter("p_patient_details",OracleDbType.RefCursor);
cmd.Parameters.Add(ssan_in).Direction = ParameterDirection.Input;
cmd.Parameters.Add(cursor_out).Direction = ParameterDirection.Output;
ssan_in.Value = "555555555";
OracleRefCursor cur = (OracleRefCursor) cursor_out.Value;
try
dbconn.Open();
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
pat_name.Text = dr["NAME"].ToString();
age.Text = dr["AGE"].ToString();
rank.Text = dr["PAY_GRADE"].ToString();
gender.Text = dr["SEX"].ToString();
pat_num.Text = dr["PATIENT_NUM"].ToString();
Any suggestions?First, you have an output parameter of type ref cursor and a return value. You shouldn't have both.
Second, try CommandType.Text and a CommandText like:
"begin :rc := find_patient(:ssan); end;"
It's easier to see how to bind the parameters like that. Bind first a OracleRefCursor output parameter, then an ssan%type InputParameter.
David -
Getting resultset from out parameter ref cursor
hi,
i have written one procedure which return one refcursor as out parameter.
when i am calling that proceduer how can i retrive that resultsets in my current program.
ex
DECLARE
type A is ref cursor;
B A;
x NUMBER :=0;
BEGIN
APPSEARCH(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,B);
FOR i in b
loop
x:= x+1;
end loop;
DBMS_OUTPUT.PUT_LINE('ANS '||x);
END;
but it is giving error
please advice
thanks
sivaThanks alessandro,
SQL> DECLARE
2 type A is ref cursor;
B A;
3 4 C b%rowtype;
5 d NUMBER;
6 BEGIN
7 APPSEARCH(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,B);
8 loop
9 fetch b into c;
10 exit when b%notfound;
11 DBMS_OUTPUT.PUT_LINE('ANS '||c%rowcount);
12 end loop;
13 close b;
14 END;
15 /
C b%rowtype;
ERROR at line 4:
ORA-06550: line 4, column 4:
PLS-00320: the declaration of the type of this expression is incomplete or
malformed
ORA-06550: line 4, column 4:
PL/SQL: Item ignored
ORA-06550: line 9, column 17:
PLS-00320: the declaration of the type of this expression is incomplete or
malformed
ORA-06550: line 9, column 4:
PL/SQL: SQL Statement ignored
ORA-06550: line 11, column 35:
PLS-00320: the declaration of the type of this expression is incomplete or
malformed
ORA-06550: line 11, column 6:
PL/SQL: Statement ignored
i dont know how to transfer the resultset from the procedure refcursor out parameter to my local cursor variable please help -
Returning a Ref cursor as an OUT Parameter
Hi Guys
I have defined 2 Types and 2 Ref cursors as shown below.I have written a procedure having 2 IN and 2 OUT parameters which are of type Ref cursors and return records to the calling client. My question is how can i test for the output of the two cursors here in pl/sql?.. also i should not close the sursors.. right?..its the job of the calling client as per my knowledge....Please suggest
TYPE type_dept_Rec IS RECORD(deptNo varchar2);
TYPE type_prod_Rec IS RECORD(prodType varchar2);
TYPE deptCursor IS REF CURSOR RETURN type_dept_Rec;
TYPE prodCursor IS REF CURSOR RETURN type_prod_Rec;
PROCEDURE TEST (pinCode IN varchar2, prodType IN number, deptCursor OUT deptType, productCursor OUT deptType) IS
BEGIN
OPEN deptCursor FOR SELECT
deptNo
from
DEPT
where
pinCode = pinCode;
OPEN productCursor FOR SELECT
prodCode
from
PROD
where
prodType = prodType;
end;A Correction to the above code snippet
Hi Guys
I have defined 2 Types and 2 Ref cursors as shown below.I have written a procedure having 2 IN and 2 OUT parameters which are of type Ref cursors and return records to the calling client. My question is how can i test for the output of the two cursors here in pl/sql?.. also i should not close the sursors.. right?..its the job of the calling client as per my knowledge....Please suggest
TYPE type_dept_Rec IS RECORD(deptNo varchar2);
TYPE type_prod_Rec IS RECORD(prodType varchar2);
TYPE deptCursor IS REF CURSOR RETURN type_dept_Rec;
TYPE prodCursor IS REF CURSOR RETURN type_prod_Rec;
PROCEDURE TEST (pinCode IN varchar2, prodType IN number, deptCursor OUT deptCursor, productCursor OUT prodCursor) IS
BEGIN
OPEN deptCursor FOR SELECT
deptNo
from
DEPT
where
pinCode = pinCode;
OPEN productCursor FOR SELECT
prodCode
from
PROD
where
prodType = prodType;
end -
OUT parameter with NOCOPY hint of type SYS_REFCURSOR
Hi,
I am having a procedure which returns a set of 100+ records (each record having 10+ columns) through a OUT parameter of type SYS_REFCURSOR.
These output records are used in JAVA code for fecthing the resultset and process data.
Will it make any difference in performance if I use NOPCOPY compiler hint in this procedure (especially I am interested in the interaction between JAVA and PLSQL, with and without NOCOPY parameter).
Thanks.
Edited by: user2946813 on Mar 25, 2012 9:15 PMuser2946813 wrote:
Hi RP,
Thanks for the answer.
So the PLSQL OUT parameter of type SYS_REFCURSOR would be passing just a reference (memory address) to JAVA.
This behavior is same with or without NOCOPY. Is my understanding correct?
Thanks.Yes. A ref cursor is just a pointer to a query, not a result set of data. Using NOCOPY or not is pointless (excuse the pun) because, no matter how much data is going to get returned, the pointer itself is no smaller or larger in size, and thus using NOCOPY won't improve performance or save resources.
{thread:id=886365} -
Hello All,
I have a small procedure like the following.
CREATE OR REPLACE procedure PROC_DEPT_SALE(SALEC_CUR out sys_refcursor)
as
begin
open sale for select * from dept_sale where dept_no='Z2341324';
end;
I just want to execute it from toad like
exec PROC_DEPT_SALE( C1);
In order to do that i need to have a sys_refcursor c1 created in my DB. I know that i can execute it as a plsql block like this
DECLARE
SALE SYS_REFCURSOR;
BEGIN
PROC_DEPT_SALE( SALE );
END;
Could anyone please let me know how can i create a TYPE REF cursor which is permanantly stored in the DB and then execute the proc the way i wanted to using the first statement.
ThanksActually, you had it correct with
CREATE OR REPLACE package cur_type as
TYPE ref_cur IS REF CURSOR;
end;but you still need to declare a variable of the type to pass the the procedure since the procedure needs to have a cursor variable to open. Given your package, the call would be more like:
DECLARE
l_cur cur_type.ref_cur;
BEGIN
proc_dept_sale(l_cur);
<do something with l_cur>
END;Forget about the cursor for a minute and think through this example. If I have a procedure that looks like:
CREATE PROCEDURE get_name (p_id IN NUMBER,
p_name OUT VARCHAR2) AS
BEGIN
SELECT last_name||', '||first_name
INTO p_name
FROM employee
WHERE emp_id = p_id;
END;I can pass a literal value to the procedure for the p_id parameter (e.g. 42) or I could pass a variable holding a value.
What do I need to pass to the procedure in p_name to get the name back out? A procedure returning a cursor is no different than this in concept.
John -
Please help....execute procedure with out parameter -cursor
HI all plese help me,
i create a stored procedure like this.hw cani execute the IN out parameter which is a cursor ir..RCT1 is cursor..
please help...
CREATE OR REPLACE PROCEDURE ST_GetTravelTypeID
TravelType IN VARCHAR2 DEFAULT NULL,
RCT1 IN OUT GLOBALPKG.RCT1
AS
BEGIN
OPEN RCT1 FOR
SELECT
TravelTypeCode,
TravelTypeDesc
FROM ST_MS_TravelTypes
WHERE TravelType = ST_GetTravelTypeID.TravelType;
END;
Message was edited by:
neethuYour reference is invalid:
WHERE TravelType = ST_GetTravelTypeID.TravelType;
This should not (cannot) refer to the name of the procedure - but simply to the variable in it. I.e.
WHERE TravelType = TravelType;
However, as you can see, the variable name is now the same as the column name.
One method around this is to use explicit scope reference. E.g.
SELECT
t.TravelTypeCode,
t.TravelTypeDesc
FROM ST_MS_TravelTypes t
WHERE t.TravelType = TravelType;I suggest that you consider this a standard for your PL/SQL programming. Always alias SQL tables in PL/SQL code and use explicit column references.
Another standard we use is to use underscore characters for columns - camel case is fine for variables in a programming language. This is not really acceptable for column names, as by default Oracle uses uppercase. Thus "TravelType" is valid as variable name, but invalid as a column name - it should be defined/written as "travel_type" or "TRAVEL_TYPE" instead. -
Calling a stored procedure with a table of custom types as a out parameter
Hi,
I'm trying to use toplink 11.1.1.0.0 to call a stored procudure with 4 in paramrs and a single out parameter of type gsearch_type which is a userdefined type defined as below
CREATE or replace TYPE search_object as object (mdlnumber varchar2(12), hit clob);
create or replace type gsearch_type as table of search_object;
Is it possible to get the return value from this stored procedure using toplink.
Thanks in advance for any help.
- SunilCurrently TopLink can't directly handle that kind of output parameter.
As a workaround you would need a wrapper for the stored procedure - it could be either another stored procedure or an anonymous block which would return the components of the complex parameter as several simple parameters. -
How to return more than one record through OUT parameter in procedure
Hi,
I want to create a procedure which accepts one input and returns more than one record as output.
example:
Input = DeptNo
Output= Empno,ename,sal,comm,job
Scenario:
There can be more than one employee in department we pass as the IN parameter. OUT parameter has to return all the records of the corresponding employee details in that department.
Thanks in advance for your help
Regards,
K.Vijay-- I think you can try something like this using ref cursor:
-- create a package for the type ref cursor and execute
CREATE OR REPLACE PACKAGE PACK_REFCURSOR_FOR_TABLES AS
TYPE DATA_TableRows IS REF CURSOR;
END;
-- after executing the package above, create your procedure:
CREATE OR REPLACE PROCEDURE GET_EMP (
IN_nDeptNo IN number,
OUT_Emp OUT PACK_REFCURSOR_FOR_TABLES.DATA_TableRows)
IS
BEGIN
-- leave query open (implicit) as this will return data
OPEN OUT_Emp FOR
SELECT *
FROM tblEmp
WHERE DeptNo = IN_nDeptNo;
END;
--execute the procedure and you're done
Maybe you are looking for
-
My ipod won't sync with my desktop
I have an ipod touch with iclouds recently installed which syncs with both my new Macbook & my older Mac desktop. I only want to use icloud to sync my address book and my iCal. I have another solution for syncing my mail and it didn't appear that I c
-
How coherence 3.5 can be configured with weblogic
Hi Guys, Can anyone help me, how to setup the coherence and configure with the weblogic server. Thank you.
-
Visibone Swatches, Photoshop, Fireworks CS5.5
Visibone swatches are great. Except in Photoshop CS5.5, the swatch set can't be made narrow enough to show it with colors properly oriented. And it's apparently not availble for Fireworks CS5 at all. I'd be grateful for any links to importable swatch
-
How to downgrade ios 8.1.2 to ios 7.1.2?
on itunes i get error 3194 ?
-
Why does opening Safari wake up my sleeping hard drives?
I have the newest of the new, best of the best i7 imac which came with Lion already on it. I'll be editing in Final Cut Pro X(sigh) and I'll go to Safari to check my email or whatever but whenever I open Safari it wakes up my sleeping hard drives whi