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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:13:04+00:00 2026-06-17T13:13:04+00:00

I have a stored procedure like create procedure Sample(sid out number,sname out varchar2) is

  • 0

I have a stored procedure like

create procedure Sample(sid out number,sname out varchar2) is
begin
select id,name into sid,sname from emp;
end;

My result should be like

id      name
------------
1      Sai
5      Hari
8      Nari

I am not able to get above array type of result how can I able to get it (without ref_cursor and with ref_cursor) ?

  • 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-17T13:13:06+00:00Added an answer on June 17, 2026 at 1:13 pm

    “without ref_cursor and with ref_cursor” is a bit confusing. without and with?

    but your outputs, if your disallowing a REF CURSOR , have to be array outputs.

    eg:

    create these types:

    create type myemptype as object (id number, name varchar2(200));
    /
    create type myemptab as table of myemptype;
    /
    

    then:

    SQL> create or replace procedure Sample(p_tab  out myemptab) is
      2  begin
      3    p_tab := myemptab();
      4    for r_emp in (select id,name from emp order by id)
      5    loop
      6      p_tab.extend;
      7      p_tab(p_tab.last) := myemptype(r_emp.id, r_emp.name);
      8    end loop;
      9  end;
     10  /
    
    Procedure created.
    
    SQL>
    SQL> declare
      2    t_emp  myemptab;
      3  begin
      4    sample(t_emp);
      5    for idx in 1..t_emp.count
      6    loop
      7      dbms_output.put_line(t_emp(idx).id || chr(9) || t_emp(idx).name);
      8    end loop;
      9  end;
     10  /
    1       Sai
    5       Hari
    8       Nari
    
    PL/SQL procedure successfully completed.
    

    or better, as a pipelined function:

    SQL> create or replace function Sample
      2  return myemptab pipelined
      3  is
      4  begin
      5    for r_emp in (select id,name from emp order by id)
      6    loop
      7      pipe row ( myemptype(r_emp.id, r_emp.name) );
      8    end loop;
      9  end;
     10  /
    
    Function created.
    
    
    SQL> col name format a10
    SQL> select * from table(sample);
    
            ID NAME
    ---------- ----------
             1 Sai
             5 Hari
             8 Nari
    

    EDIT with scalar arrays:

    SQL> create type myempidtab as table of number;
      2  /
    
    Type created.
    
    SQL> create type myempnametab as table of varchar2(20);
      2  /
    
    Type created.
    
    SQL> create or replace procedure Sample(p_id out myempidtab ,p_name out myempnametab) is
      2  begin
      3    p_id := myempidtab();
      4    p_name := myempnametab();
      5    for r_emp in (select id,name from emp order by id)
      6    loop
      7      p_id.extend;
      8      p_name.extend;
      9      p_id(p_id.last) := r_emp.id;
     10      p_name(p_name.last) := r_emp.name;
     11    end loop;
     12  end;
     13  /
    
    Procedure created.
    
    SQL> declare
      2    t_id    myempidtab;
      3    t_name  myempnametab;
      4  begin
      5    sample(t_id, t_name);
      6    for idx in 1..t_id.count
      7    loop
      8      dbms_output.put_line(t_id(idx) || chr(9) || t_name(idx));
      9    end loop;
     10  end;
     11  /
    1       Sai
    5       Hari
    8       Nari
    
    PL/SQL procedure successfully completed.
    
    SQL>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure with an IN OUT parameter declared like follows: create
I want to (loosely) have a stored procedure like select * from table where
I have a stored procedure which basically does something like select top 1 expiryDate,
I have a really simple stored procedure that looks like this: CREATE PROCEDURE _Visitor_GetVisitorIDByVisitorGUID
I have stored procedure like CREATE procedure [dbo].[spAddItem] ( @itemId nvarchar(50), @itemName nvarchar(500), @itemDescription
Say we have stored procedure(s) performing simple operations like this: CREATE PROCEDURE [dbo].[AddNewAuthorReturnID] (
I have a stored procedure that looks like: CREATE PROCEDURE dbo.usp_TestFilter @AdditionalFilter BIT =
I would like to have a stored procedure that return 3 results. these results
I'm very new to MySQL and I have a stored procedure that I'd like
I have a line in my SQL Stored Procedure that looks like this (works

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.