A  Transaction Manager  allows defining actions interposed to the events of INSERT, DELETE or UPDATE of a SQL object acting as a program trigger (non-resident in database).

1 Events

1.1 INSERT

In this example, a SQL statement will be added to update the total amount of the invoice whenever a new invoice line is inserted.

Parameters of the box:

Sentence used:

Copy
UPDATE invoice SET total = (SELECT SUM(unitprice*quantity) FROM invoiceline WHERE invoiceid = #invoiceid) WHERE invoiceid = #invoiceid

Result:

1.2 DELETE

In this example, a statement will be added in the xsql-script language, by means of which the total amount of the invoice will be updated after having deleted a line in the invoice.

Parameters of the box:

Sentence used:

Copy
<call name='invoice_line_del'>
<args>
<arg>#invoiceid</arg>
</args>
</call>

Result:

1.3 UPDATE

In this example, a sentence will be added through an embedded script that will allow updating the total amount of the invoice if there is any change in quantity or unit price at line level of the invoice.

Parameters of the box:

Sentence used:

Copy
<call>
<![CDATA[

<xsql-script name='invoice_line_upd'>

<body>

<drop table='@tmp_lines_invoice' onexception='ignore'/>
<select intotemp='@tmp_lines_invoice'>
<columns>
SUM(quantity*unitprice) total_line
</columns>
<from table='invoiceline'/>
<where>
invoiceid = #invoiceid
</where>
</select>

<select prefix='m_'>
<columns>
SUM(total_line) total_inv
</columns>
<from table='@tmp_lines_invoice'/>
</select>

<update table='invoice'>
<column name='total'><m_total_inv/></column>
<where>
invoiceid = #invoiceid
</where>
</update>

</body>

</xsql-script>

</call>

Result: