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.
Author |
Topic |
shubhada
Posting Yak Master
117 Posts |
Posted - 2007-08-07 : 02:15:05
|
I have a proc as following DECLARE @id_temp_tran int, @num_updated int, @num_failed int, @batch_count int, @id_tran int, @id_imnt int, @status int, @count_imnt int, @id_typ_tran varchar(20), @dt_chg_grd datetime, @id_own_grd int, @debug smallint, @id_client varchar(50), @id_tran_seq int, @id_typ_event char(7)SELECT @count_imnt = 0DECLARE crsr_imnt cursor forselect id_imnt from tempdb..ANVIL_IDSFOR READ ONLYgoOPEN crsr_imntFETCH crsr_imnt INTO @id_imntWHILE @@sqlstatus = 0BEGIN EXEC @status = PYR_TRADE..dim_get_tran_id @id_tran = @id_tran OUTPUT IF @status = 0 BEGIN EXEC PYR_TRADE..dim_create_event_imnt @id_tran = @id_tran, @id_tran_seq = 1, @id_typ_event = 'INSERT', @id_imnt = @id_imnt, @debug = 1 EXEC PYR_TRADE..dim_create_event_transaction @id_tran = @id_tran, @id_typ_tran = 'INSTRUMENT', @debug = 1 INSERT INTO tempdb..ANVIL_TRAN VALUES(@id_tran) SELECT @count_imnt = @count_imnt + 1 END ELSE BEGIN print "Failed to get a DIM transaction ID for anvil id_imnt %1!.", @id_imnt END FETCH crsr_imnt INTO @id_imntEND -- WhileCLOSE crsr_imntDEALLOCATE CURSOR crsr_imntgoBut at the time of execution ,I am getting the following error Msg: 7344, Severity 15, Line 19ErrorMsg: DECLARE CURSOR must be the only statement in a query batch.Plz tell me how to overcome this problemSQLTeam |
|
pootle_flump
1064 Posts |
Posted - 2007-08-07 : 03:10:07
|
Remove the GO after READ ONLY. |
 |
|
shubhada
Posting Yak Master
117 Posts |
Posted - 2007-08-07 : 03:12:24
|
tried but still gettiing the same error..SQLTeam |
 |
|
Jim77
Constraint Violating Yak Guru
440 Posts |
Posted - 2007-08-07 : 03:56:40
|
WHILE @@sqlstatus = 0should be changed toWHILE @@FETCH_STATUS <> -1 FETCH crsr_imnt INTO @id_imntshould be changed to for both occurances.FETCH NEXT FROM crsr_imnt INTO @id_imnt |
 |
|
|
|
|
|
|