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 8919933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:08:49+00:00 2026-06-15T06:08:49+00:00

Can an Oracle SQL procedure return a table? I’m currently using a dbms_output to

  • 0

Can an Oracle SQL procedure return a table? I’m currently using a dbms_output to print out the outputs of two cursors which are in a loop, although this would look nicer if it was returning two columns instead. Would that be possible within a procedure?

  • 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-15T06:08:50+00:00Added an answer on June 15, 2026 at 6:08 am

    A PL/SQL function can return a nested table. Provided we declare the nested table as a SQL type we can use it as the source of a query, using the the TABLE() function.

    Here is a type, and a nested table built from it:

    SQL> create or replace type emp_dets as object (
      2  empno number,
      3  ename varchar2(30),
      4  job varchar2(20));
      5  /
    
    Type created.
    
    SQL> create or replace type emp_dets_nt as table of emp_dets;
      2  /
    
    Type created.
    
    SQL> 
    

    Here is a function which returns that nested table …

    create or replace function get_emp_dets (p_dno in emp.deptno%type)
        return emp_dets_nt
    is
        return_value emp_dets_nt;
    begin
        select emp_dets(empno, ename, job)
        bulk collect into return_value
        from emp
        where deptno = p_dno;
        return return_value;
    end;
    /
    

    … and this is how it works:

    SQL> select * 
      2  from table(get_emp_dets(10))
      3  /
    
         EMPNO ENAME                          JOB
    ---------- ------------------------------ --------------------
          7782 CLARK                          MANAGER
          7839 KING                           PRESIDENT
          7934 MILLER                         CLERK
    
    SQL> 
    

    SQL Types offer us a great deal of functionality, and allow us to build quite sophisticated APIs in PL/SQL. Find out more.

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

Sidebar

Related Questions

I am using a PL/SQL procedure to extract Oracle tables of a particular schema
Can PL/SQL procedure in Oracle know it's own name? Let me explain: CREATE OR
In Oracle / SQL Server I can use the WITH keyword to define a
How can I connect to an Oracle database and SQL Server 2005-2008 database with
How can I make a sql SELECT query run forever in oracle 10g? It
I work for a ISV. Our product can use both SQL Server and Oracle
Can anyone provide a working sample code to convert following Oracle DB table with
In Oracle, we can use FOR employee_rec in (select id from mytbl) LOOP DBMS_OUTPUT.PUT_LINE(employee_rec.id);
How can I achieve the following in oracle without creating a stored procedure? Data
I'm having some troubles executing oracle stored procedure from package. I've intalled PL/SQL developer

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.