I have following code in a procedure, it works fine in the Sybase ASA 6, but after migrating it to the 12.5 version, it gives error.
Here's the basic example of the code:
while(@@sqlstatus = 0) begin declare crs_sid dynamic scroll cursor for select s_th from dba.table where s_var in(1,2,3) open crs_sid with hold fetch next crs_sid into @sid while(@@sqlstatus = 0) begin .. fetch next crs_sid into @sid end close crs_sid end
Here's the error I get:
AFAIK, cursor names must be unique in current SA releases - I don't know whether that was different in very old days... (BTW, you're not using version 12.5, as that would be an ASE version, right?)
Confine this discussion (though it's based on FOR loops - but they do use cursor names, too):
There you'll find the definite answer by Ivan, as documented in DCX for the DECLARE CURSOR statement: