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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:46:11+00:00 2026-05-13T23:46:11+00:00

Could anyone tell me how to bulk insert data from a ref cursor to

  • 0

Could anyone tell me how to bulk insert data from a ref cursor to a temporary table in PL/SQL? I have a procedure that one of its parameters stores a result set, this result set will be inserted to a temporary table in another stored procedure.

This is my sample code.

CREATE OR REPLACE PROCEDURE get_account_list
(
type_id in account_type.account_type_id%type,
acc_list out sys_refcursor
)
is
begin
    open acc_list for
    select account_id, account_name, balance
    from account
    where account_type_id = type_id;
end get_account_list;

CREATE OR REPLACE PROCEDURE proc1
(
   ...
)
is
    accounts sys_refcursor;
begin
    get_account_list(1, accounts);

    --How to bulk insert data in accounts to a temporary table?


end proc1;

In SQL Server, I can write as code below

CREATE PROCEDURE get_account_list    
   type_id int
as
   select account_id, account_name, balance
   from account
   where account_type_id = type_id;



CREATE PROCEDURE proc1
(
  ...
)
as
   ...

   insert into #tmp_data(account_id, account_name, balance)
   exec get_account_list 1

How can I write similar to the code in SQL Server? Thanks.

  • 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-05-13T23:46:11+00:00Added an answer on May 13, 2026 at 11:46 pm

    you can use BULK operations on REF CURSOR:

    SQL> CREATE GLOBAL TEMPORARY TABLE gt (ID NUMBER);
    
    Table crÚÚe.
    
    SQL> DECLARE
      2     l_refcursor SYS_REFCURSOR;
      3     TYPE tab_number IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
      4     l_data tab_number;
      5  BEGIN
      6     OPEN l_refcursor FOR
      7        SELECT ROWNUM FROM dual CONNECT BY LEVEL <= 1e6;
      8     LOOP
      9        FETCH l_refcursor BULK COLLECT
     10           INTO l_data LIMIT 100;
     11
     12        FORALL i IN 1..l_data.count
     13           INSERT INTO gt VALUES (l_data(i));
     14
     15        EXIT WHEN l_refcursor%NOTFOUND;
     16
     17     END LOOP;
     18     CLOSE l_refcursor;
     19  END;
     20  /
    
    ProcÚdure PL/SQL terminÚe avec succÞs.
    

    Oracle 10g already implements this optimization for regular loop though, so you may not see much improvement from a simple LOOP…INSERT.

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

Sidebar

Ask A Question

Stats

  • Questions 372k
  • Answers 372k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The EJB specification don't specify how clustering should be achieved,… May 14, 2026 at 7:12 pm
  • Editorial Team
    Editorial Team added an answer An ASP.NET application (by default) will execute in IIS6 under… May 14, 2026 at 7:12 pm
  • Editorial Team
    Editorial Team added an answer I don't use PostgreSQL but if you don't find a… May 14, 2026 at 7:12 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.