grille11
2005-02-24 15:10:22 UTC
Hello everyone,
I am trying to use the cursor function in a simple script like this one (not a stored procedure) :
Declare @FNBsetid int
Declare FNBcur CURSOR FOR
select * from comp_data
Open FNBcur
Fetch FNBcur into @FNBsetid
while (@@sqlstatus = 0)
BEGIN
-- this
insert into attr_config (id) values (@FNBsetid)
Fetch FNBcur into @FNBsetid
END
CLOSE ColuList
DEALLOCATE cursor ColuList
This works in a stored procedure but when I run this in a sql interface (sql advantage for instance) I have this error
Error: Number (7344) Severity (15) State (1) Server (server) DECLARE CURSOR must be the only statement in a query batch.
Would there be a way to make this work in a simple sql scritp?
Would anyone have an idea on this?
Thanks in advance for your help
I am trying to use the cursor function in a simple script like this one (not a stored procedure) :
Declare @FNBsetid int
Declare FNBcur CURSOR FOR
select * from comp_data
Open FNBcur
Fetch FNBcur into @FNBsetid
while (@@sqlstatus = 0)
BEGIN
-- this
insert into attr_config (id) values (@FNBsetid)
Fetch FNBcur into @FNBsetid
END
CLOSE ColuList
DEALLOCATE cursor ColuList
This works in a stored procedure but when I run this in a sql interface (sql advantage for instance) I have this error
Error: Number (7344) Severity (15) State (1) Server (server) DECLARE CURSOR must be the only statement in a query batch.
Would there be a way to make this work in a simple sql scritp?
Would anyone have an idea on this?
Thanks in advance for your help