Showing results for 
Search instead for 
Did you mean: 

Issues with cursor

Former Member
0 Kudos

Hi All,

We have a cursor declared in a stored procedure.

While debugging this stored procedure, I noticed that if there are 10 rows (for example) satisfying the cursor criterion, when we loop through the cursor

data using "while @@sqlstatus =0", the cursor is looping for only 4 rows (for example).

So the cursor is not fetching all the rows satisfying the cursor criterion. Can any one explain this.

I hope I explained my issue clearly.



Accepted Solutions (0)

Answers (1)

Answers (1)

Active Contributor
0 Kudos

Clear so far, but some more details would be helpful.

What is your ASE version (select @@version)?

What is the cursor definition?

Does the loop do anything that would modify the data between fetches?


Former Member
0 Kudos

Hi Bret,

The ASE version is 15.7.

The cursor definition is like :

select distict <columns> from #temp_table (index test_index)

where column1=@li_column and .......

for read only

And the loop does update the data for each fetch.

I also noticed that, if i remove the index from the cursor definition, the loop is processing all the

data satisfying the cursor definition.

- Kiran