1 try
<try>
<body /> !
<catch /> !
</try>
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Ebody | string | ||||
Ecatch | string |
Remarks
The code lines could cause an exception must be contained between the start and end mark of the label <body>. The set of actions to execute, if an exception is produced, has to be inside of the tag <catch>.
[...] <try> <body> <connection.begin /> <select prefix='m_'> <columns>COUNT(*) cnt</columns> <from table='gcommovd'> <join table='galmctas' alias='a'> <on>gcommovd.ctaori = a.code</on> </join> <join table='galmctas' alias='b'> <on>gcommovd.ctades = b.code</on> </join> </from> <where> gcommovd.code = <m_tipdoc/> AND a.indsal != 'N' AND b.indsal != 'N' </where> </select> [...] <execute-procedure name='gcommovh'> <in> <select> <columns>rowid</columns> <from table='gcommovh' /> <where>cabid = <m_cabtra/></where> </select> </in> </execute-procedure> <connection.commit /> </body> <catch> <connection.rollback /> <insert table='tmp_plan_err' columns='errmsg'> <value><error.message/></value> </insert> </catch> </try> [...]
This example code shows a case of transactions use through the sentence <try>. The set of lines that could cause an exception, starts with the start transaction senetence <connection.begin>. In the case of that an unexpected situation between the start and end mark of the label <body>, the block of actions contained in the tag <catch> is executed. This block begans with the element <connection.rollback>, undoing the changes that were performed from the start of the transaction until the instruction that causes the exception.