Previous Topic Next topic Print topic


DELETE (Searched)

Removes table rows that meet the search criteria.

Syntax:

>>--EXEC SQL--.-------------------.---DELETE--.------.--->
              +-FOR :host_integer-+           +-FROM-+

 >--.-table_name-.--.-------------------------.-END-EXEC-><
    +--view_name-+  +-WHERE search_conditions-+

Parameters:

host_integer A host variable that specifies the maximum number of host array elements processed. Must be declared as PIC S9(4) COMP-5 or PIC S9(9) COMP-5.
FROM An optional keyword. It is required for ANSI SQL 92 conformance.
table_name The target table for the delete operation.
view_name The target view for the delete operation.
WHERE A standard SQL WHERE clause identifying the row to be deleted.
search_conditions Any valid expression that can follow the standard SQL WHERE clause.

Comments:

DELETE is a standard SQL statement. See the documentation supplied with your ODBC driver for the exact syntax.

You cannot mix simple host variables with host arrays in the WHERE clause. If one of the host variables is an array, they must all be arrays.

If you do not specify a WHERE clause, all of the rows in the named table are removed.

Example:

EXEC SQL
   DELETE FROM staff WHERE staff_id = 99
END-EXEC
Previous Topic Next topic Print topic