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)
 Error with multiple cursors in a stored procedure

Author  Topic 

d
Starting Member

26 Posts

Posted - 2001-12-19 : 09:30:23
I have a stored procedure move_data where I have declared 3 cursors:

declare A_cursor cursor for
......

declare B_cursor cursor for
......

declare C_cursor cursor for
......

In begin..end , based on some conditions I either open A_cursor or B_cursor, C_cursor.

However, when I execute my procedure, it says the following:

Server: Msg 16915, Level 16, State 1, Line 0
A cursor with the name 'A_cursor' already exists.
Server: Msg 16915, Level 16, State 1, Procedure move_data, Line 51
A cursor with the name 'B_cursor' already exists.
Server: Msg 16915, Level 16, State 1, Procedure move_data, Line 93

It does not mention an error for C_cursor since based on the conditions in begin..end, C_cursor got opened.

Why am I getting the error???

Any help will be greatly appreciated.

Thanks.


robvolk
Most Valuable Yak

15732 Posts

Posted - 2001-12-19 : 10:48:09
Can you post your entire code? Don't worry about how big it is. Multiple cursors are not only tricky but serious performance killers, we might be able to rewrite it as a set based process.

Go to Top of Page
   

- Advertisement -