Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8945511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:15:50+00:00 2026-06-15T12:15:50+00:00

This may find little silly, but I would like to know whether this is

  • 0

This may find little silly, but I would like to know whether this is possible.

I have a function which return sys_refcursor

CREATE OR REPLACE FUNCTION get_employee_details(p_emp_no IN EMP.EMPNO%TYPE)
   RETURN SYS_REFCURSOR
AS
   o_cursor   SYS_REFCURSOR;
BEGIN
   OPEN o_cursor FOR
      SELECT EMPNO,
             ENAME,
             JOB,
             MGR,
             HIREDATE,
             SAL,
             COMM,
             DEPTNO
        FROM emp
       WHERE EMPNO = p_emp_no;

   RETURN o_cursor;
 -- exception part
END;
/

and I could get the results using

select  get_employee_details('7369') from dual;

Is it possible to get the result from the above function by specifying column name?
E.g. If I would want to get ename or salary, how could I specify in the sql statement without using a plsql block?
Something like

select  get_employee_details('7369') <specific column> from dual;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:15:51+00:00Added an answer on June 15, 2026 at 12:15 pm

    No, not with a ref cursor at all, and otherwise not without creating SQL types to cast the return into, like this example: http://dbaspot.com/oracle-server/9308-select-ref-cursor.html:

    create or replace type myType as object (
    a int,
    b varchar2(10)
    )
    /
    
    create or replace type myTable as table of myType;
    /
    
    create or replace function f1 return myTable as
    l_data myTable := myTable();
    begin
    for i in 1 .. 5 loop
    l_data.extend;
    l_data(i) := myType(i, 'Row #'||i );
    end loop;
    return l_data;
    end;
    /
    
    select * from TABLE ( cast( f1() as myTable ) );
    
    ---------- ----------
    1 Row #1
    2 Row #2
    3 Row #3
    4 Row #4
    5 Row #5
    

    From the last post on that thread:

    the way you already knew about is the only one to use
    the REF CURSOR in a select statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this may seem like a simple problem but I couldn't find it in the
This may sound like a stupid question but I can't seem to find an
This may sounds like a stupid question but can't find anything on google, probably
I know this question may be a little bit common and over asked but
This may be super easy to solve but I can't find the correct google
This may be a simple question but I can;t find the answer anywhere. Here
This question may sound too silly, however , I don't find concrete answer any
This may be a stupid question but I have a code with the following
This may be have a better name than custom tab completion, but here's the
The title may seem a little weird but what I find around the internet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.