@@FETCH_STATUS Issues

  • Has anybody seen any mutiprocessor envrironment related issues if there are mutiple queries running in parallel and depending on @@FETCH_STATUS variable. We are experiencing some inconsistent unexplanable data and suspecting usage of @@FETCH_STATUS?

    FYI. I am using this variable immediatly after the cursor fetch statement!

  • From BOL.

    "Because @@FETCH_STATUS is global to all cursors on a connection, use @@FETCH_STATUS carefully. After a FETCH statement is executed, the test for @@FETCH_STATUS must occur before any other FETCH statement is executed against another cursor. The value of @@FETCH_STATUS is undefined before any fetches have occurred on the connection.

    For example, a user executes a FETCH statement from one cursor, and then calls a stored procedure that opens and processes the results from another cursor. When control is returned from the called stored procedure, @@FETCH_STATUS reflects the last FETCH executed in the stored procedure, not the FETCH statement executed before the stored procedure is called."

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply