The UPDATE statement allows you to modify records in a table.
 

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>
Example
Copy
<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.

Example
Copy
<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>
Example

Modify or insert a record.

Copy
<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.