
13/11/2010, 20:04
|
| | Fecha de Ingreso: noviembre-2010
Mensajes: 100
Antigüedad: 14 años, 3 meses Puntos: 0 | |
Respuesta: cursor en mysql Le qite el isset, ahora quedaria asi, ayuda xfa... aun siue sin dar -- --------------------------------------------------------------------------------
-- 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 (cantidad>=0) 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// |