You can use the EGL delete statement
to delete one or more rows from a relational database table.
Syntax
- delStatement
- A single SQL DELETE statement, which is not required to end with
a semicolon but can. The statement format is as shown for entity.
You
can use a prepared statement in place of #sql{delStmt}.
- entity
- Name of the entity, which is a variable based on an External type,
Handler type, or Record type. The values in that entity are used in
the corresponding SQL DELETE statement. If you specify the SQL data
source but not an SQL statement, the following default is used:
DELETE from tableName
where ID_column_1 = ? AND
ID_column_2 = ? AND... ID_column_n = ?)
The
value of tableName is the value of the Table annotation
that is set on the entity type. If that annotation is missing from
the type definition, the value of tableName is the type name.
An ID_column entry
such as ID_column_1 is a name; specifically, the value of the Column annotation
for a field in the type definition. If that annotation is missing
from the field in the type definition, the name in the statement is
the name of the field in the type definition.
The default DELETE
statement references only the columns key fields, which are
the entity fields that have an ID annotation. The order of
the column fields in the statement reflects the order of the key fields.
Each
question mark in the
values clause is replaced with a value:
- For default processing, the behavior is as follows:
- If you do not specify the using clause, the replacement
value is the corresponding value in the entity.
- If you specify a using clause, the replacement value is
the corresponding value in the using clause.
- If you specify an entity and a custom SQL DELETE statement, the
behavior is as follows:
- If you do not specify the using clause, the replacement
value is the corresponding value in the entity.
A question mark
represents the value of a key field, with the first question mark
corresponding to the first key field, the second question mark to
the second key field, and so forth. The statement can include fewer
question marks than the number of key fields but cannot include more.
- If you specify a using clause, the replacement value is
the corresponding value in the using clause. In this case,
you can reference fields other than key fields.
- field
- A value of an EGL simple type that is compatible with the corresponding
database column. The list of simple values is assigned to the question
marks in the SQL DELETE statement.
- SQLDataSource
- A variable of type SQLDataSource. The variable includes
connection details or references an EGL deployment descriptor entry
that provides access to the connection details.
If you issue a
prepared statement, the variable is optional and is ignored if present.
- SQLResultSet
- An SQL result set that was established by an open statement.
In this case, the Delete statement deletes the current row.
An attempt to delete the row a second time results in an exception.
Compatibility
Table 1. Compatibility
Target |
Issue |
Java |
No issues |
JavaScript |
Database access is not supported in JavaScript.
|