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)
 How to store @@FETCH_STATUS into a local variable

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-31 : 10:02:40
Jack writes "How do I manage @@FETCH_STATUS in nested cursors? I understand that @@FETCH_STATUS is global to all scripts and procedures.
For example;
DECLARE First_cursor CURSOR FOR
select DayNum,Time_id from tblMedLog where MedUID=21
OPEN Med_cursor
WHILE @@FETCH_STATUS = 0
BEGIN
-- Use another cursor ( second_cursor ) here and use @@FETCH_STATUS to control the looping


END

I have tried select @@FETCH_STATUS = @MyFetchStatus; does not work!"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-01-31 : 10:08:57
eeeeeeeeewwwwwwwwwwwww, cursors!

eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeewwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww, nested cursors!

quote:
I have tried select @@FETCH_STATUS = @MyFetchStatus; does not work!"


Actually, if you switch it around you should be OK:

SELECT @MyFetchStatus=@@FETCH_STATUS

When assigning a value to a user variable, the variable needs to be on the left side of the equal sign.

Go to Top of Page
   

- Advertisement -