Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/11/2010, 18:44
programajin
 
Fecha de Ingreso: noviembre-2010
Mensajes: 100
Antigüedad: 13 años, 6 meses
Puntos: 0
cursor en mysql

hola a todos, xfavor ayudenme, tengo el siguiente cursor:

-- --------------------------------------------------------------------------------
-- Routine DDL
-- --------------------------------------------------------------------------------
DELIMITER //

CREATE PROCEDURE `corporac_burmes`.`actualiza_todo_compra` (in compra int, in suma float,in tienda int)
BEGIN

DECLARE done INT DEFAULT 0;
DECLARE a,b INT;
DECLARE cantidad INT;
DECLARE cur1 CURSOR FOR SELECT cantidad,producto_id FROM detalle_compra_producto where compra_id=compra and vigencia=1;

DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;

OPEN cur1;


REPEAT
FETCH cur1 INTO a, b;

IF NOT done THEN
set cantidad=(select cantidad from detalle_tienda_producto where producto_id =b);

IF isset(cantidad) THEN
set cantidad=cantidad+a;
update detalle_tienda_producto set cantidad=cantidad where producto_id=b;
ELSE
INSERT INTO detalle_tienda_producto (cantidad,producto_id,tienda_id) VALUES (a,b,tienda);
END IF;
END IF;
UNTIL done END REPEAT;

CLOSE cur1;



END//



no encuentro el error, xfavor recien toy implementando esto de cursor, para poder actualizar, pero no me sale nada :S