Deletion of records in tables. Returns the number of deleted registers.

1 delete

<delete
    secure='secure'
    table='table'
>
    <where> !
        <condition /> !
    </where>
    <where-current-of /> ?
</delete>

Exceptions

database required

The database is not informed.

The specified table is not in the database.

The tables does not exists.

required attribute [...]

A required attribute has not been informed.

Remarks

To remove registers of a table is necessary to indicate the database with the parameter "-dbms" and the user with the parameter "-user".

If you want to delete registers without any condition, you should create a condition which is met for all the registers, for example, 1 = 1.

If you use where-current-of, the select should carry the attribute for-update='yes' to indicate that the cursor is will not only be read but will be modified. It is also necessary to open transaction before the foreach.

Example

Remove registers.

Copy
<xsql-script name='delete_sample1'>
    <body>
        <set name='cenllote_loteid'>136</set>
        <delete table='nombre de tabla'>
            <where>loteid = <cenllote_loteid/></where>
        </delete>
    </body>
</xsql-script>

The registers are remove of the table "ccon_interfase" whose value of the column loteid coincide with the content of the variable cenllote_loteid.

Example

Example of use of the tag 'where-current-of': all the registers of the table 'cdiary' is deleted.

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