Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 11 to 12 of 12 total |
About locks |
Tue, Aug 5 2008 11:26 AM | Permanent Link |
Francisco Fernandez | Ok, i've changed the trigger like that:
BEGIN DECLARE TempCursor CURSOR FOR stmt; DECLARE TempCantidad DECIMAL(12,2); WHILE TRUE DO START TRANSACTION ON TABLES Proveedores; BEGIN PREPARE stmt FROM 'SELECT * FROM Proveedores WHERE CODIGO COLLATE ESP_CI=?'; OPEN TempCursor USING NEWROW.PROVEEDOR; FETCH FROM TempCursor (TOTALC) INTO TempCantidad; If TempCantidad IS NULL THEN UPDATE TempCursor SET TotalC=NEWROW.TOTALBASE; ELSE UPDATE TempCursor SET TotalC=TempCantidad+NEWROW.TOTALBASE; END IF; UPDATE TempCursor SET FECHAULTC=NEWROW.FECHA; COMMIT; LEAVE; EXCEPTION RAISE ERROR CODE 10000 MESSAGE 'Error al grabar'; END; END WHILE; END ... but it don't leave after commit and it save and save and save all the time, i must cut program. |
Tue, Aug 5 2008 12:26 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Francisco,
<< .. but it don't leave after commit and it save and save and save all the time, i must cut program. >> Well, you don't need the WHILE loop if you're just always issuing an exception with RAISE in the EXCEPTION block. But, if you want to keep the loop because you're going to add some more processing in the EXCEPTION block for retrying, etc., then use this: BEGIN DECLARE TempCursor CURSOR FOR stmt; DECLARE TempCantidad DECIMAL(12,2); WHILE TRUE DO START TRANSACTION ON TABLES Proveedores; BEGIN PREPARE stmt FROM 'SELECT * FROM Proveedores WHERE CODIGO COLLATE ESP_CI=?'; OPEN TempCursor USING NEWROW.PROVEEDOR; FETCH FROM TempCursor (TOTALC) INTO TempCantidad; If TempCantidad IS NULL THEN UPDATE TempCursor SET TotalC=NEWROW.TOTALBASE; ELSE UPDATE TempCursor SET TotalC=TempCantidad+NEWROW.TOTALBASE; END IF; UPDATE TempCursor SET FECHAULTC=NEWROW.FECHA; COMMIT; EXCEPTION ROLLBACK; RAISE ERROR CODE 10000 MESSAGE 'Error al grabar'; END; LEAVE; END WHILE; END Notice that I included a ROLLBACK call - you were missing that. -- Tim Young Elevate Software www.elevatesoft.com |
« Previous Page | Page 2 of 2 | |
Jump to Page: 1 2 |
This web page was last updated on Monday, May 6, 2024 at 12:23 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |