Database Mashable Transactions
For database mashables created in Presto 2.7.0 or earlier, you can add transaction handling using these Presto extension statements:
<presto:beginTransaction>: opens a connection to the database associated with the mashable specified in the command and sets AutoCommit to false.
<presto:commitTransaction>: sends a commit message to the database associated with the mashable specified in the command and closes the database connection.
<presto:rollbackTransaction>: sends a rollback message to the database associated with the mashable specified in the command and closes the database connection. The
Presto Server also automatically sends a rollback for any invocation failures for the specified Database service within the bounds of the transaction.
Important: | For transaction handling for database mashables created in later versions of Presto, see SQL Transactions. |
The Presto Server does not support distributed transactions. These commands only affect the invocations for a specific database mashable. All other commands are unaffected, including invocations of other services.
Transaction Example
This sample uses a database mashable with operations to insert, update or delete records in several Personnel tables.
...
<presto:beginTransaction service="personnel"/>
<invoke service="personnel" operation="addEmployee"
inputvariables="newEmployee" outputvariable="employeeResult"/>
<invoke service="personnel" operation="addDemographics"
inputvariables="newEmployee" outputvariable="$demoResult"/>
<invoke service="personnel" operation="addBenefits"
inputvariables="newEmployee" outputvariable="$benefitsResult"/>
<if condition="$employeeResult/response/response/errorcode = 300
or $demoResult/response/response/errorcode = 300
or $benefitsResult/response/response/errorcode = 300">
<presto:rollbackTransaction service="personnel"/>
<else>
<presto:commitTransaction service="personnel"/>
</else>
</if>
...