SELECT DIRECT statement (select direct statement: searched)
The SELECT DIRECT statement (
select direct statement: searched) selects a row in a table. A specified key value is used for the selection.Syntax
<select_direct_statement:_searched> ::= SELECT DIRECT <select_column>,...
INTO <parameter_spec>,... FROM <table_name> KEY <key_spec>,...
[<where_clause>] [<lock_option>]
Explanation
The select direct statement is used to access a particular row in a table directly by specifying the key columns. For tables defined without key columns, there is the implicitly generated column SYSKEY CHAR(8) BYTE which contains a key generated by the database system. The table column SYSKEY, therefore, can be used in the select direct statement to access a specific table row.
The user must have the SELECT privilege for the selected columns or for the entire table.
If a row with the specified key values is found and if a
search condition specified for this row is true, the corresponding column values are assigned to the parameters. The FETCH statement rules apply for assigning the values to the parameters.If there is no row with the specified key values, or if a row with the specified key values does exist but a search condition defined for this row is not true, the return code
100 - ROW NOT FOUND - is issued and no values are assigned to the parameters specified in the parameter specifications.INTO <parameter_spec>
is not necessary in interactive mode.The lock option determines which lock is set for the read row.
A LONG column can only be specified in a selected column in the uppermost sequence of selected columns in this SELECT DIRECT statement.
See also:
SELECT DIRECT statement (select_direct_statement:_positioned)