Open statement for a relational database

The open statement opens a result set, which is a variable of type SQLResultSet. That variable can be instantiated only by issuing the open statement.

Syntax



Syntax diagram for the open statement with SQL

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 SELECT statement.
If you specify an entity and do not specify the SQL statement, the following default is used:
SELECT 
   column_1, column_2... column_n
   FROM tableName
   WHERE ID_column_1 = ? AND ID_column_2 = ? ... AND ID_column_n = ?
The default SELECT statement retrieves data from all columns in the table:
  • The order of the column fields in the statement reflects the order of the fields in the type definition.
  • A column entry such as 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 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.

The default WHERE clause references only the key fields, which are the entity fields that have an ID annotation. The order of the columns listed in the WHERE clause reflects the order of the key fields.

When you are specifying an entity, each question mark 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 SELECT 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.
SQLStmt
A prepared statement, which is a variable of type SQLStatement. The variable must have been instantiated by issuing the EGL prepare statement.
stmt
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}.


Compatibility

Table 1. Compatibility
Target Issue
Java No issues
JavaScript Database access is not supported in JavaScript.