Para evitarlo debemos declarar el cursor con la clausula WITH HOLD. Esta clausula puede utilizarse tanto en r4gl como en un Stored Procedure.
En STORED PROCEDURES:
CREATE PROCEDURE 'informix'.procedureName()
FOREACH WITH HOLD
SELECT column1, column2 INTO var1, var2 FROM table1WHERE condicion
BEGIN WORK;
---
---
UPDATE table2 SET column1 = column1 - var1 WHERE condicion;
UDPATE table3 SET column1 = column1 + (column1 * var2 / 100)
WHERE condicion;
---
---
COMMIT WORK;
END FOREACH;
END PROCEDURE;
En R4GL:
DECLARE cursorName CURSOR WITH HOLD FOR
SELECT column1, column2 FROM table1 WHERE condicion
FOREACH cursorName INTO var1, var2
BEGIN WORK;
---
---
UPDATE table2 SET column1 = column1 - var1 WHERE condicion;
UDPATE table3 SET column1 = column1 + (column1 * var2 / 100)
WHERE condicion;
---
---
COMMIT WORK;
END FOREACH
Espero que os sea de utilidad.
No hay comentarios:
Publicar un comentario