Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Cursors

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-05-17 : 17:27:54
Farouk writes "Hi All,

I am developing a complex stored procedure which makes use of plus/minus 5 cursors, I am not having a problem with the cursors itself, the problem I am having is with the @@Fetch_Status global variable.

Please refer to example below:

Eg.

Declare Outer_Cursor Cursor For
(Select RowId From Receipt)
Open Outer_Cursor

Fetch Next From Outer_Cursor into @Local_Variable

While (@@FETCH_STATUS = 0)
Begin
Set @Test = @Local_Variable
Declare Inner_Cursor For
(Select Name From Supplier Where ID = @Test)
Open Inner_Cursor

Fetch Next From Inner_Cursor into @Supplier_Name

While (@@FETCH_STATUS = 0)
Begin
...
...
...and so it goes

Does the @@FETCH_STATUS with regrad to the Inner_Cursor have an effect on the result of the @@FETCH_STATUS with regard to the Outer_Cursor.

Because in any other programming language changes to a global variable are GLOBAL.

Any feedback, would be highly appreciated.

Thanx"
   

- Advertisement -