DELETE (positioned) Statement [ESQL] [SP]

Deletes the data at the current location of a cursor.

Syntax

DELETE [ FROM table-spec ]
WHERE CURRENT OF cursor-name

Parameters

Examples

Usage

This form of the DELETE statement deletes the current row of the specified cursor. The current row is defined to be the last row fetched from the cursor.

The table from which rows are deleted is determined as follows:
  • If no FROM clause is included, the cursor can only be on a single table.

  • If the cursor is for a joined query (including using a view containing a join), you must use the FROM clause. Only the current row of the specified table is deleted. The other tables involved in the join are not affected.

  • If you include a FROM clause and do not specify table owner, table-spec is first matched against any correlation names.
    • If a correlation name exists, table-spec is identified with the correlation name.

    • If a correlation name does not exist, table-spec must be unambiguously identifiable as a table name in the cursor.

  • If a FROM clause is included, and a table owner is specified, table-spec must be unambiguously identifiable as a table name in the cursor.

The positioned DELETE statement can be used on a cursor open on a view as long as the view is updatable.

Changes effected by positioned DELETE statements are visible in the cursor result set, except where client-side caching prevents seeing these changes.

See also Reference: Building Blocks, Tables, and Procedures > System Procedures > System Stored Procedures > sp_iqcursorinfo Procedure.

Standards

  • SQL—The range of cursors that can be updated may contain vendor extensions to ISO/ANSI SQL grammar if the ANSI_UPDATE_CONSTRAINTS option is set to OFF.

  • Sybase—Embedded SQL use is supported by Open Client/Open Server. Procedure and trigger use is supported in SQL Anywhere.

Permissions

Must have DELETE permission on tables used in the cursor.

Related reference
DECLARE CURSOR Statement [ESQL] [SP]
INSERT Statement
UPDATE Statement
UPDATE (positioned) Statement [ESQL] [SP]