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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:43:26+00:00 2026-06-10T07:43:26+00:00

In my stored procedure, I have a code snippet like this: OPEN p_result FOR

  • 0

In my stored procedure, I have a code snippet like this:

OPEN p_result FOR
SELECT *
FROM TABLE (CAST ( l_data AS Rpt_mapping_TableType));
COMMIT;

p_result is an IN OUT parameter of type SYS_REFCURSOR.Rpt_mapping_TableType is a user defined collection type.
So this cursor will just populate the Rpt_mapping_TableType and then the program that calls this proc will read the results from Rpt_mapping_TableType.
My question is what is the use of COMMIT in this snippet? The code author says it is a way of closing the cursor. Is it right? My other question is if I just want to populate the collection , do I even need to do OPEN p_result FOR. After all I am not reading anything from the cursor so :

SELECT *  FROM TABLE (CAST ( l_data AS Rpt_mapping_TableType));

should suffice.

No?

  • 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-10T07:43:27+00:00Added an answer on June 10, 2026 at 7:43 am

    A commit will not close a cursor. If it did, then your code wouldn’t work. (Although it could unlock rows from a FOR UPDATE, causing other problems.) Here’s an example of a commit not closing a cursor:

    SQL> variable test refcursor
    SQL> begin
      2  open :test for select 1 from dual;
      3  end;
      4  /
    
    PL/SQL procedure successfully completed.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> print test;
    
             1
    ----------
             1
    
    SQL>
    

    If you just want to populate a collection, you’re probably better off using something like SELECT ... BULK COLLECT INTO ... instead. (And possibly using a LIMIT.) The keyword CURSOR is frequently over-used. Unless you’re passing data to another program, implicit cursors and bulk collects are usually much simpler and faster.

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

Sidebar

Related Questions

I have inherited code that looks like this: Stored Procedure UpdateSomeStuff Update Table1 Set
I have code like below, this stored procedure 'get2Rows' returns 2 rows, i want
So in C# to use a stored procedure I have code like the following
I have this code which calls a stored procedure within ZEND. Is there a
I have the code below to query records from a stored procedure but am
I have the following code within a stored procedure. WHERE WPP.ACCEPTED = 1 AND
I have ADO.Net code as below, that calls a stored procedure. Within the stored
I have the following stored procedure that I have to get data from: EXECUTE
Say I have a stored procedure consisting of several separate SELECT, INSERT, UPDATE and
Ok this is the scenario... I have a table in Oracle that acts like

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.