senzacionale
senzacionale

Reputation: 20916

mysql cursor and count number of loops. how to count number of loops in mysql cursor

How can i count number of loops in cursor

declare counter int;

set counter := 1;
    open cursor1;                           
    LOOP1: loop      

set counter := counter + 1; 

    end loop LOOP1;

but i get error of:

[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'set counter := counter + 1; 

    end loop LOOP1;

Upvotes: 0

Views: 2206

Answers (1)

scessor
scessor

Reputation: 16115

Maybe you have to remove the : in the set to solve the sql syntax error:

set counter = 1;

and

set counter = counter + 1;

Upvotes: 1

Related Questions