1 Update
Modifies the records in the table that meet the condition indicated in the where clause. From these records, modifies the values of the specified columns with the column tag.
<update table='table'>
<column
name='name'
text='text'
/> +
<where /> ?
</update>
Attributes | |||||
---|---|---|---|---|---|
Name | Type | Required | Default | Description | |
Atable | string | Table name. |
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Ecolumn | Value to assign to the column. | ||||
Aname | string | Column name. | |||
Atext | string | true to be able to use an SQL expression or function to get the value. | |||
Ewhere | Condition of selection of records to be modified. |
<update table='gcomfacl'> <column name='estlin'>V</column> <column name='impnet' text='true'>ROUND(impnet, 2)</column> <where> cabid = <p_cabid /> </where> </update>
Modifies the value of the estlin column of the purchase invoice lines with identifier contained in the p_cabid variable.
<update table='gcompedh'> <column name='estcab'><string>E</string></column> <column name='errcab'><number>0</number></column> <column name='wkfcab'><null /></column> <where> cabid = <p_cabid /> </where> </update>
Modifies the estcab, errcab and wkfcab fields of the purchase order header with identifier contained in the variable p_cabid .
Check selection condition
It is advisable before executing the update, to ensure that the where clause selects exactly the records to be modified. For example, checking the result of executing a query to the same table with the same selection condition.
2 Update-or-insert
Allows you to modify a record of a table, and if it does not exist, it inserts it.
<update-or-insert>
<update /> +
<insert /> +
</update-or-insert>
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Eupdate | update clause that defines the update operation that will be performed to try to modify the table. | ||||
Einsert | If no record has been modified after the execution of the previous update statement, this clause describes the insert operation that will be executed. |
Modify or insert a record.
<update-or-insert> <update table="wic_mobile_apks"> <column name="apk_notes"><p_notes /></column> <column name="apk_bytes"><file.bytes.read><file type='absolute' name='#p_file' /></file.bytes.read></column> <where> apk_code = <p_code /> AND apk_version = <p_versiob> </where> </update> <insert table="wic_mobile_apks"> <column name="apk_code"><p_code /></column> <column name="apk_version"><p_version /></column> <column name="apk_notes"><p_notes /></column> <column name="apk_bytes"><file.bytes.read><file type='absolute' name='#p_file' /></file.bytes.read></column> </insert> </update-or-insert>
Return
Returns a numeric value:
0 if the update operation has modified any record.
If no record has been modified and the insert statement has been executed, it returns the serial number of the inserted record.