## SINGLE SELECT statement (single_select_statement)

A SINGLE SELECT statement (single_select_statement) specifies a result table with one row and assigns the values in this row to parameters.

### Syntax

<single_select_statement> ::=
SELECT [<distinct_spec>] <select_column>,...
INTO <parameter_spec>,... FROM <from_table_spec>,...
[<where_clause>] [<group_clause>] [<having_clause>] [<lock_option>]

### Explanation

The number of rows in the result table must not be greater than one. If the result table is empty or contains more than one row, corresponding messages or return codes are issued and no values are assigned to the parameters specified in the parameter specifications. The return code 100 – row not found - is set if the result table is empty.

If the result table contains just one row, the values of this row are assigned to the corresponding parameters. The FETCH statement rules apply for assigning the values to the parameters.

The order of the GROUP and HAVING clauses is random.

A LONG column can be specified in a selected column select_column in the uppermost sequence of selected columns in a single select statement only if the DISTINCT specification distinct_spec DISTINCT was not used there.