Catalogued transactions allow SOAP clients to perform transactions in a safe environment.

1 Overview

Menu path:
Web Services / SQL catalog (Deprecated) / SQL Transactions

Clients invoke a catalogued transaction by sending the code of the transaction trx_code and the type of transaction ( trx_type ): Insert, Update, Delete or Execute along with the data required to perform the transaction. Note that the table is not sent by the client, this prevents SOAP clients from executing transacctions to arbitrary tables on the system.

wic_sqlc_trx_ins_head
Label Description
Code Code
Type Type of transaction. Valid types are Insert, Delete, Update, Execute

  • Default: I
  • Case: Upshift
  • Values:
    • I: Insert. Create a new register to a table
    • D: Delete. Delete one register to a table
    • U: Update. Modify one register of a table
    • E: Execute. Execute an xsql-script.
    • V: Update or Insert. Update or Insert
Table The table on which the transaction will be performed
Columns Columns

Pre-XSQL Script An XSQL-Script invoked before performing the transaction
Post-XSQL Script An XSQL-Script invoked after performing the transaction
Validation statement

SQL sentence that when informed must return at least one row and be non zero, otherwise the transaction will not be performed. It is possible to reference field of the transaction using the ${field} notation. For instance:

SELECT COUNT(*) FROM gcrm_consulh WHERE tercer = ${USER} AND rowid = ${rowid} AND estado == 'O'


Information Information

Created by The user who has created the record

  • Default: USER
Date created Date of registering

  • Default: CURRENT
Modified by The last user who has updated the record

  • Default: USER
Date updated Date of the last update

  • Default: CURRENT

2 Validation query

The field trx_sec contains an SQL query that is executed before the transaction and allows to enforce further security to the transaction. If the query does not return rows or returns a single row with a 0, then the transaction is not allowed to proceed. The query statement can contain references to the transcation data using the notation ${fieldName}.

3 Pre processing

Before the transction is performed, an xsql-script can be executed by informing the field before_xsql_code. The script gets as arguments:

  1. The name of the table of the transaction
  2. A map with the values that will be used for the transaction. This map can be edited to prevent or add column values involved in the transaction

The XSQL-Script is executed in the same database SQL transaction, therefore if a rollback occurs inside the xsql script execution, the whole transaction will be rolled back. This can be used to implement complex validations.

Copy
<xsql-script name='fr_cajcobr_prv_insert'>
   <args>
        <arg name='p_table' type='string'   />
        <arg name='p_map'   type='map'      />
    </args>

    <body>
        
        <set name='m_usercode'><system.user.getCode /></set>
        
        <select prefix='m_'>
            <columns>
                liqid
            </columns>
            <from table='gret_caja' />
            <where>
                numtpv = <m_usercode /> AND
                revtpv = 0
            </where>
        </select>
        
        <map.put name='p_map'><string>liqid</string><m_liqid/></map.put>
        <map.put name='p_map'><string>cantid</string>0</map.put>
        <map.put name='p_map'><string>impteo</string>0</map.put>
        <map.put name='p_map'><string>cobid</string>0</map.put>
      
    </body>
</xsql-script>

4 Post processing

After the transaction is performed an XSQL-Script can be excuted if the field xsql_code is informed. The script receives as arguments:

  1. The name of the table of the transaction
  2. The rowid of the row affected by the transaction
  3. The type of transaction : Insert, Delete, Update, Execute

The XSQL-Script is executed in the same database SQL transaction, therefore if a rollback occurs inside the xsql script execution, the whole transaction will be rolled back

When trx_type is of type Execute, then post processing xsql-script is not executed, only before_xsql_code script is executed

Copy
<xsql-script name='fr_parte_mail2sms'>
    <args>
        <arg name='p_table' type='string'   />
        <arg name='p_rowid' type='integer'   />
        <arg name='p_action' type='string'  />
    </args>

    <body>
        
        <select>
            <columns>
                par_id p_parid
            </columns>
            <from table='gaut_parte'>
            </from>
            <where>
                rowid = <p_rowid />   
            </where>
        </select>
        
        <if>
            <expr>
                <not>
                    <select>
                        <columns>COUNT(*)</columns>
                        <from table='gaut_ordrepa'>
                            <join table='gaut_parte'>
                                <on>gaut_ordrepa.vped_docser = gaut_parte.vped_docser</on>
                            </join>
                        </from>
                        <where>
                             gaut_parte.par_id = <p_parid />   
                        </where>
                    </select>
                </not>
            </expr>
            <then>
                <return />
            </then>
        </if>
        
    </body>
</xsql-script>