iterate through temporary table ..
Posted on 2004-11-01
I am new to db queries.
I have a situation where i have to iterate through each row of a temp table in sybase and update another table based on the temptables value.
I am able to do this through cursors (fetch the values of temptable and update the second table), but it is taking too long to execute.
Is there a way that i can iterate through the temptable using a while loop or similar.
declare cursor temp_cur for
select colA, colB, colC from tableA where colA = 'something'
open cursor temp_cur
fetch into .. .
if @@sqlstatus = 0
<i have some statements for every value of colA here>
can i just loop through the temp table instead ?
select cola, colb, colC into #temptable1 where colA = 'something'
while #temptable1.eof .. :) (plz forgive this poor ASP programmer)
If yes, how do i do it ?