ALLBASE/SQL Reference Manual (36216-90216)

Chapter 12 501
SQL Statements S - Z
SELECT
QueryExpression
is a complex expression specifying what is to be selected. The query
expression is made up of one or more query blocks, as described in the
chapter "SQL Queries."
ORDER BY sorts the result table rows in order by specified columns. Specify the sort
key columns in order from major sort key to minor sort key. You can specify
as many as 1023 columns. The column specified in the ORDER BY
parameter must be one of the columns appearing in the SELECT list. Data
is returned in descending order when the ORDER BY
columnID
DESC
clause is specified.
For each column you can specify whether the sort order is to be ascending
or descending. If neither ASC nor DESC is specified, ascending order is
used.
ColumnID
must correspond to a column in the select list. You can identify a column to
be sorted by giving its name or by giving its ordinal number, with the first
column in the select list being column number 1. You must use a column
number when referring to columns in the query result that are derived
from column expressions. You must also use a column number to refer to
columns if the expression contains more than one query block.
The syntax for a column ID in the ORDER BY clause follows:
{
ColumnNumber
[[
Owner.
]
TableName.
CorrelationName.
]
ColumnName
}
Description — Select Statement Level
The SELECT statement is considered updatable if the query expression it contains is
updatable and if no ORDER BY clause is present.
The BULK option cannot be used interactively or in a procedure.
ALLBASE/SQL uses file space in the defined TempSpaces, and in the system files when
processing queries containing ORDER BY clauses or UNION operators. (No such space
is used during UNION ALL.)
When using this statement to select LONG columns, the name of the file is returned in
the appropriate field in the
HostVariableSpecification
specified within the
QueryExpression
. With the BULK option, if the output mode is specified with $, then
each LONG column in each row accessed has a file with a unique name containing the
LONG data retrieved. Additionally, the data file is generated in the directory specified
when the LONG column was defined.
SQL Syntax — Subquery Level
(
QueryExpression
)