Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2009
    Posts
    4

    Unanswered: SQL Server - Cursor Issue

    I have a situation wherein Program A is calling Program B. Program B has the cursor that it opens the first time Program B is called. After the Open, Program B sets a flag to indicate that the cursor is open and then goes on to Fetch the 1st record and sends it back to Program A. Program A then calls program B again and this time, its expected that the program B would directly do a fetch since it knows that Cursor is already open. But the system is giving the error that Cursor is not open. I am somehow losing the Open once I go back to program A. Is there a way to hold the Cursor position, so that I dont have to do the Open again and just fetch the next record when I call Program B.

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    avoid cursors 99% of the time you think you need one. use set based processing.

    why 2 programs? this sounds like a scop issue. the 2 programs can not use the same cursor that is in the scope of the session of the other.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Dec 2009
    Posts
    4
    Program A is not using any cursor. It just uses the data that is passed from Program B. Only one program - Program B is having the cursor and thats the only program where the fetch takes place. We are migrating programs from Db2 to SQL. So we dont have choice to eliminate cursors

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •