Try OpenEdge Now
skip to main content
Developing WebSpeed Applications
Controlling Database Transactions : Multi-page database transactions : Managing multi-page DB transactions
 

Managing multi-page DB transactions

The mechanism for controlling multi-page database transactions consists of two web-utilities-hdl method procedures that you can execute within process-web-request:
*set-transaction-state (INPUT t-state), where t-state is a character string that can take these values:
*"START[-PENDING]" — Begin a multi-page transaction when this request service ends (when the WebSpeed agent returns to a LOCKED state or is no longer in a BUSY state).
*"UNDO[-PENDING]" — Undo the current multi-page transaction when this request service ends.
*"COMMIT[-PENDING]" — Commit the current multi-page transaction when this request service ends.
*"RETRY[-PENDING]" — Undo the current multi-page transaction when this request service ends and immediately start a new database transaction.
Note: You can drop the "-PENDING" suffix when you set a transaction state.
*get-transaction-state, which returns the current transaction state, t-state, as the value of the RETURN-VALUE SpeedScript function, including these values:
*"NONE" — There is no multi-page database transaction active on this agent.
*"START-PENDING" — A multi-page transaction will be started on this agent before the next request service (no agent transaction is currently active).
*"ACTIVE" — There is an active multi-page database transaction on this agent.
*"UNDO-PENDING" — The current multi-page transaction will be undone by the start of the next request service.
*"COMMIT-PENDING" — The current multi-page transaction will be committed by the start of the next request service.
*"RETRY-PENDING" — The current multi-page transaction will be undone and a new multi-page transaction started before the start of the next request service.
As you can see, get-transaction-state can return two more states than you can set with set-transaction-state. This is because when you start or terminate a multi-page transaction, there is no effect until the next request service in the current agent transaction. Thus, a transaction state of ‘NONE' means both that there is no multi-page database transaction current and none has been requested. Likewise, a transaction state of "ACTIVE" means both that there is an active multi-page transaction and no termination request has been issued.
Conversely, if the transaction state is "UNDO-PENDING" or "COMMIT-PENDING", there is an active transaction that will terminate by the next Web request service on this agent. "RETRY-PENDING" means there is an active transaction that will be thrown away and there will be a new active transaction by the start of the next request.
Note that you cannot set any state at any time. Some transaction states preclude the setting of others and an error is returned when you violate theses requirements:
*"START" can only be set if the current transaction state is "NONE".
*"UNDO", "RETRY", and "COMMIT' can only be set if the current transaction state is "ACTIVE".
Thus, you cannot change a transaction state that you have previously set in the same request service.
Although you cannot start a multi-page transaction when no WebSpeed transaction is active on the agent, you receive no error for trying. The agent (web-disp.p) resolves the transaction request with the "NONE" state by default.