Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can I select from a sys_refcursor?

xmouseJul 3 2009 — edited Jul 3 2009
Anybody guide me?

I have had a procedure as follow.
PROCEDURE P_Cache_AllFriends(
    p_MEMBER_ID IN NUMBER,
    p_curResult OUT SYS_REFCURSOR
) AS
BEGIN
    OPEN p_curResult FOR
    SELECT YF.FRIEND_ID
    FROM FRIENDS YF
    WHERE YF.MEMBER_ID = p_MEMBER_ID; 
END P_Cache_AllFriends;
This procedure was called in php code. So I can change it. Now I want to write a query to get all subjects of all friends of a member with the list of friend identifiers are returned from the above procedure. Could I write the query like that?
DECLARE
    p_curFriend SYS_REFCURSOR;
    p_curSubject SYS_REFCURSOR;
BEGIN
    P_Cache_AllFriends( 
        p_MEMBER_ID => 123456,
        p_curResult => p_curFriend
    );
    
    OPEN p_curSubject FOR
    SELECT * 
    FROM SUBJECTS
    WHERE MEMBER_ID IN (....<p_curFriend>....)
END;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 31 2009
Added on Jul 3 2009
6 comments
52,247 views