Problem with cursor in MySQL

0

Good afternoon!

I am successfully creating the following cursor:

declare v_cursor cursor for
    select idCliente, max(dataVenda) from Cliente
    left join Venda on idCliente = cliente_idCliente
    group by idCliente;

But when I run the command fetch I get the following error:

  

Error code 1329, SQL state 02000: No data - zero rows fetched,   selected, or processed

Apparently he charges that select did not return any tuple to the cursor. However, when I run select isolated, it returns data :

Can anyone tell me why this happens?

Is there a way around this?

Thank you!

    
asked by anonymous 07.11.2014 / 20:20

1 answer

1

The HANDLER statement was missing:

DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

Source: link

    
07.11.2014 / 21:43