Results 1 to 7 of 7

Thread: CURSOR Problem

  1. #1
    Join Date
    Sep 2009
    Location
    Kentucky
    Posts
    3

    Unanswered: CURSOR Problem

    Hello everyone:

    I am new to this forum and learning SQL lenguage.

    I am "stepping" through a stored procedure but when I try to run a cursor section it gives me the following error:

    DECLARE CURSOR must be the only statement in a query batch.

    How do you test a declare cursor section when you stepping a stored procedure?

    Thanks in advance!!

  2. #2
    Join Date
    Sep 2003
    Location
    Switzerland
    Posts
    443
    What debug program you are using to step thro?
    Quote Originally Posted by rodre01
    Hello everyone:

    I am new to this forum and learning SQL lenguage.

    I am "stepping" through a stored procedure but when I try to run a cursor section it gives me the following error:

    DECLARE CURSOR must be the only statement in a query batch.

    How do you test a declare cursor section when you stepping a stored procedure?

    Thanks in advance!!

  3. #3
    Join Date
    Sep 2009
    Location
    Kentucky
    Posts
    3
    I am using SQLDBX...

  4. #4
    Join Date
    Sep 2003
    Location
    Switzerland
    Posts
    443
    Quote Originally Posted by rodre01
    I am using SQLDBX...
    Never had any personal experience with it. But looks like its crapping out because it doesnt know some SQL happened before. In other words a bug in it. If this product is not GNU and you bought it, I would raise a case against them.

  5. #5
    Join Date
    Mar 2009
    Location
    Sydney, Australia
    Posts
    258
    Stepping through sprocs takes a bit of understanding.
    1 The tools out there (commercial, priced, or Open Source) do anywhere from a middling to a horrible job.
    2 There is a Sybase proc debugger, but that has only come out recently, and the Tools have not integrated it yet.
    3 You always fall back on:
    - cut-and-paste code segments from the sproc, into a separate window (based on your tool)
    - starting from the inner-most code segment, to the outer-most
    - execute those code segments separately, until you obtain success
    - then build up those code segments (inner-most to outer-most), maintaining success for the expanding code segment
    - until you get to the point where you have finished (you just need to wrap the code segment with a "create proc as", etc. to produce a true proc)

    Once you understand this, the error msgs are easy to get around. Just cut-an-paste the cursor declaration plus the fetch into a window in your tool, and execute it. Then add the code within the loop, so you have the declaration, the fetch, and the loop. And so on.
    Regards
    Derek Asirvadem (Formerly DerekA)
    Information Architect / Senior Sybase DBA
    Copyright 2009 Software Gems Pty Ltd

    I answer questions from the Original Poster only. If you have a genuine question, as the moderators have requested, start a new thread.

    http://www.softwaregems.com.au

  6. #6
    Join Date
    Sep 2009
    Location
    Kentucky
    Posts
    3
    Hello Derek:

    I was able to run the cursor.

    Thanks for your help!!!!

  7. #7
    Join Date
    Mar 2009
    Location
    Sydney, Australia
    Posts
    258
    My pleasure. Thanks for the feedback.
    Regards
    Derek Asirvadem (Formerly DerekA)
    Information Architect / Senior Sybase DBA
    Copyright 2009 Software Gems Pty Ltd

    I answer questions from the Original Poster only. If you have a genuine question, as the moderators have requested, start a new thread.

    http://www.softwaregems.com.au

Posting Permissions

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