transactionsopenedgeprogress-4gl

Apply changes in a sub transaction in Progress


I'm trying to apply changes and release the changed tables in a sub transaction but not yet in the main transaction.

Like so:

MAIN_TRANSACT:
DO TRANSACTION:
    
    // do stuff

    SUB_TRANSACT:
    DO TRANSACTION:
        // change stuff
        FIND testTable WHERE ... SHARE-LOCK.
        IF AVAILABLE testTable THEN DO: 
            testTable.value = "new value".
            RELEASE testTable.
        END.
    END. // apply
    
    // do stuff

END.

But all what progress does, is not apply the data after the end of the sub transaction.

What i tried:

I tried to do it like Tom said here and use a different file with a different session.

// main.p

DEFINE VARIABLE hSubFile AS HANDLE NO-UNDO.
IF NOT VALID-HANDLE(hSubFile) THEN DO:
    RUN sub.p PERSISTENT SET hSubFile.
END.

MAIN_TRANSACT:
DO TRANSACTION:
    
    // do stuff

    RUN subTransaction IN hSubFile.
    
    // do stuff

END.

DELETE OBJECT hSubFile NO-ERROR.
// sub.p

PROCEDURE subTransaction:

    SUB_TRANSACT:
    DO TRANSACTION:
        // change stuff
        FIND testTable WHERE ... SHARE-LOCK.
        IF AVAILABLE testTable THEN DO: 
            testTable.value = "new value".
            RELEASE testTable.
        END.
    END. // apply
    
END PROCEDURE.

But this didn't work, but I also think I did it wrong. Since this did not really spawn a new "_progress.exe" process.

I hope someone can help me.


Solution

  • The OpenEdge DB does not support committing a sub-transaction so that it survives a roll-back of the actual transaction.

    An AppServer request can be a solution, as the AppServer will be doing a separate transaction. But

    a) you may first have to add the AppServer to your architecture and b) in case you want to undo the work done by the AppServer, that cannot be controlled from the calling procedure.

    Instead of using the AppServer, you could OS-COMMAND another _progres session. That may simplify issue a) - but won't help with b) either.