Skip to main content
April 18, 2006
Answered

Ref Cursor and type

  • April 18, 2006
  • 6 replies
  • 584 views
Hi all

I finally got the Ref Cursor stored procedure working but am stuck on the following. I have this package body:

CREATE OR REPLACE PACKAGE BODY PACK_MYCURSOR AS
PROCEDURE REFCUR (
theuserid IN OUT users.user_id%type,
userfirstname OUT users_TableRows) IS
BEGIN
OPEN userfirstname FOR
select * from users
where user_id = theuserid
;
END REFCUR ;
END PACK_MYCURSOR ;
/

Now this is working fine, but I would need to have explisit fields in the select statement, like "select user_id from users", but when I do this then I get error messages of "expression is of wrong type". Anybody know how to solve this?

Thank you.
This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer paross1
Declare your ref cursor as WEAK type instead of STRONG. In other words, do not specify RETURN rowtype%ROWTYPE in your declaration in the spec.

Declare as:
TYPE users_TableRows IS REF CURSOR;

Phil

6 replies

paross1Correct answer
Participating Frequently
April 18, 2006
Declare your ref cursor as WEAK type instead of STRONG. In other words, do not specify RETURN rowtype%ROWTYPE in your declaration in the spec.

Declare as:
TYPE users_TableRows IS REF CURSOR;

Phil
April 18, 2006
You don't know how many hours I spend on this...Thank you. I am in the middle of reading a PL/SQL Book but some things are just not so easy to grasp :-)
Participating Frequently
April 18, 2006
If you want a GREAT PL/SQL reference, read Oracle PL/SQL Programming by Steven Feuerstein from O'Reilly. In my opinion, Feuerstein is the guru of gurus for PL/SQL, and he is easy to read and follow.

Phil