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>
Attributes | |||||
---|---|---|---|---|---|
Name | Type | Required | Default | Description | |
Atable | string | Name of the table. | |||
Aprepare | boolean | False to skip the prepare of the sentence. | |||
Aprepare-cache | boolean | Indicate if the prepared statement must be stored in cache for successive uses. This allows to cache the SQL sentence and to reuse it changing only the values to modify (optimize the performance). | |||
Asecure | boolean | True to inherit the security of the rol of the BD connection group to which belongs the user. This flag is always true if the select is being executed from dbconmgr or soap call with code xsql embebed (not cataloged). |
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Eids-directive | null | Allows you to indicate optimization directives for the execution SQL sentence in a database with engine ids. | |||
Evalue | string | Optimization directives for databases ids. | |||
Eoracle-directive | null | Allows to indicate optimization directives for the execution SQL sentence in a database with engine oracle. | |||
Evalue | string | Optimization directive for databases oracle. | |||
Edb2u-directive | null | Allows you to indicate optimization directives for the execution SQL sentence in a database with engine db2u. | |||
Evalue | string | Optimization directive for databases db2u. | |||
Edb2i-directive | null | Allows you to indicate optimization directives for the execution SQL sentence in a database with engine db2i. | |||
Evalue | string | Optimization directive for databases db2i. | |||
Emysql-directive | null | Allows you to indicate optimization directives for the execution SQL sentence in a database with engine mysql. | |||
Evalue | string | Optimization directive for databases mysql. | |||
Esqlserver-directive | null | Allows you to indicate optimization directives for the execution SQL sentence in a database with engine sqlserver. | |||
Evalue | string | Optimization directive for databases sqlserver. | |||
Epostgres-directive | null | Allows you to indicate optimization directives for the execution SQL sentence in a database with engine postgres. | |||
Evalue | string | Optimization directive for databases postgres. | |||
Ecolumn | string | Column's name. | |||
Atext | boolean | Indicate if the column should be 'prepared' or not. If it is not 'prepared', the sentence is built as a string. If it is 'prepared' the values are established when the sentence is built. When you indicate that the update should not be 'prepared', then any column is 'prepared'. | |||
Evalue | string | New value for the column. | |||
Ewhere | string | Selection condition for the registers that should be modified. | |||
Econdition | string | ||||
Ewhere-current-of | string | Replace the 'where'. it refers in each round to the record that is being treated at that moment. | |||
Evalues | string | Values for the condition fields of the WHERE clause. | |||
Evalue | string |
Returns | |
---|---|
Type | Description |
integer | Number of modified registers. |
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.
Modify registers of a table.
<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 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.
<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>
Update with optimization for the ids.
<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>