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

  • Home
  • SEARCH
  • 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 6795509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:21:15+00:00 2026-05-26T18:21:15+00:00

I have created a procedure(p1). This procedure opens a cursor(c1). And i call another

  • 0

I have created a procedure(p1). This procedure opens a cursor(c1). And i call another procedure(p2) in loop for each row of cursor. Procedure takes 22 secs to 120 secs.
In procedure P1, i open, close and deallocate cursor c1. This works fine.

Now procedure P1 has a input. So ,i have written another procedure (p3) with cursor (c2).
Cursor c2 gets input for p1. Now row count for C2 is 1403. So i call P1, 1403 times from P3.
And this creates error:

Error: Cursor trying to open C1, is already open.

I understand that Sql server tries to run P1 simultaneously for many rows in C2. And as C1 is already open, So comes the error.

Any idea, how i can restrict P3 to execute P1 one at a time.

  • 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-26T18:21:16+00:00Added an answer on May 26, 2026 at 6:21 pm

    How are you declaring the cursor C1 in P1? Is it a LOCAL or a GLOBAL cursor? A LOCAL cursor should be able to be declared as many times as you like, as its only used within the scope of the single procedure.

    DECLARE customerCursor LOCAL
    

    If GLOBAL/LOCAL is not defined for the cursor, it will use the database default value (from CURSOR_DEFAULT) which starts off as GLOBAL.

    If the above doesn’t help, would it be possible to see simplified versions of your procedures for easier testing?

    Regards,
    M

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

Sidebar

Related Questions

I have created a Stored Procedure, that looks like this: DELIMITER €€ CREATE PROCEDURE
I have this stored procedure: CREATE OR REPLACE PROCEDURE LIQUIDACION_OBTENER ( p_Cuenta IN NUMBER,
I have created the following stored procedure.. CREATE PROCEDURE [dbo].[UDSPRBHPRIMBUSTYPESTARTUP] ( @CODE CHAR(5) ,
I have just created a report in Report Manager using a Stored Procedure which
I have a modal dialog that is created with the following: procedure TFormCompose.createParams(var Params:
I have a dynamic SQL statement I've created in a stored procedure. I need
I created and launch the SQLJ Java procedure (using SQL Developer). I have some
I have created a test (not real) encryption function which takes a byte[] and
i have a Stored Procedure which returns output as a ref cursor. I would
i have this procedure for inserting rows in tables(sql server 2005) CREATE PROCEDURE ans_insert

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.