Allows to modify registers of a table. Returns the number of modified registers.

1 update

<update
    table='table'
    prepare='true|false'
    prepare-cache='true|false'
    secure='true|false'
>
    <ids-directive> ?
        <value /> +
    </ids-directive>
    <oracle-directive> ?
        <value /> +
    </oracle-directive>
    <db2u-directive> ?
        <value /> +
    </db2u-directive>
    <db2i-directive> ?
        <value /> +
    </db2i-directive>
    <mysql-directive> ?
        <value /> +
    </mysql-directive>
    <sqlserver-directive> ?
        <value /> +
    </sqlserver-directive>
    <postgres-directive> ?
        <value /> +
    </postgres-directive>
    <column text='text'> +
        <value /> !
    </column>
    <where> ?
        <condition /> !
    </where>
    <where-current-of /> ?
    <values> ?
        <value /> !
    </values>
</update>

Exceptions

database required

You need to specify the database.

The specified table is not in the database.

The tables does not exist.

required attribute [...]

A required attribute has not been informed.

no columns specified in update comman

The columns has not been specified.

Remarks

To modify registers is necessary that the user will be identified and that you select a database. This is informed through the options -user and -dbms of the command ws-dbscript.

If where-current-of is used, the select must bring the attribute for-update='yes' to indicate that the cursor will not be only-read but it can be modified. Also it is necessary to open transaction before the foreach.

Example

Modify registers of a table.

Copy
<xsql-script name='update_sample1'>
    <body>
        <set name='cenllote_loteid'>136</set>
        <update table='ccon_interfase'>
            <column name='codemp'>23</column>
            <where>loteid = <cenllote_loteid/></where>
        </update>
    </body>
</xsql-script>
Example

Example of use of the tag 'where-current-of': in all the registers of the table 'cdiary' you should put the field 'nomdia' in capital letters.

Copy
<xsql-script name='update_sample2'>
   <body>
       <!-- It is necessary to open transaction. -->
       <connection.begin />
        <foreach>
           <!-- You shouyld indicate to the cursor that it will be modified. -->
           <select for-update='yes'>
               <columns>*</columns>
               <from table='cdiary' />
           </select>

           <do>
               <update table='cdiary'>
                   <column name='nomdia' text='true'>UPPER(nomdia)</column>
                   <where-current-of />
               </update>
           </do>
       </foreach>
       <connection.commit />
   </body>
</xsql-script>
Example

Update with optimization for the ids.

Copy
<xsql-script>
   <body>
         ....
       <update table='gdwh_ctersecs'><ids-directive>--+INDEX(gdwh_ctersecs, "i_gdwh_ctersecs1")</ids-directive>
           <column name='canmov'>canmov + p_canmov</column>
         ....
   </body>
</xsql-script>