Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query Analyzer - code not running the second time.
Message
From
08/07/2003 20:57:14
Rene Lovino
Bigfoot Global Solutions, Inc
Cebu, Philippines
 
 
To
08/07/2003 14:10:23
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
00808133
Message ID:
00808282
Views:
10
When I lauch the Query Analizer the first time and run some code for the first time the insertions work fine.
If I run the same code again I get a message saying the following :

The command(s) completed successfully.>

But, the problem is that the insertions did not work!.

For them to work again I will need to close the Query Analizer and open it again.

Here is the code that I run:

use vips
DECLARE @ac varchar(40)
DECLARE agency_cursor CURSOR FOR SELECT ac FROM agt_data
OPEN agency_cursor
WHILE (@@FETCH_STATUS = 0)
BEGIN
FETCH NEXT FROM agency_cursor INTO @ac
PRINT @ac
INSERT INTO pt_agency (ProducerCode) VALUES (@ac)
END
CLOSE agency_cursor
DEALLOCATE agency_cursor
GO


Thanks,
Sergio


Sergio,

Change your code as follows:

OPEN agency_cursor
FETCH NEXT FROM agency_cursor INTO @ac
WHILE (@@FETCH_STATUS = 0)
BEGIN
PRINT @ac
INSERT INTO pt_agency (ProducerCode) VALUES (@ac)
FETCH NEXT FROM agency_cursor INTO @ac
END

This is the proper code that you need using cursor.

Rene
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform