|
|
SELECT
Retrieves data from the tables in the database.
Usage
Embedded/Interactive/ODBC/Procedural/JDBC.
In ESQL, the
SELECTstatement may only be used to declare a cursor or as input to aPREPAREstatement.In a procedural usage context, the
SELECTstatement may only be used to declare a cursor.In interactive SQL, the
SELECTstatement is used for interactive data retrieval. See the Mimer SQL User's Manual, Retrieving Data for more details.Description
SELECT Statements
Simple
SELECTstatements are built from aselect-expression, see The SELECT Expression, optionally followed by aFOR UPDATE OFclause.
SELECTstatements are used in embedded SQL (including procedural usage contexts) to define cursors and as the input to dynamicPREPAREstatements.The embedded
SELECTstatement is syntactically equivalent to the interactive data retrievalSELECTstatement. In embedded contexts however, the statement cannot be used to retrieve data directly but must be implemented through a cursor.The FOR UPDATE OF Clause
If the
SELECTstatement defines a cursor forUPDATE CURRENTstatements, afor-update-ofclause may be optionally used to list the columns to be updated. If thefor-update-ofclause is used, it must include all the columns to be updated.Each column specified in the
for-update-ofmust belong to the table or view named in thefromclause of theSELECTstatement, although the columns in FOR UPDATE OF do not need to be specified in theselectclause. No column may be named more than once in thefor-update-ofclause.Column names in the
for-update-ofclause may not be qualified by the name of the table or view. They are implicitly qualified by the table reference in thefromclause of the select specification.FOR UPDATE OF may not be specified if the statement defines a read-only result set, see Updatable Result Sets.
Updatable Result Sets
A result set is only updatable if all of the following conditions are true (otherwise the result set is read-only):
- the keyword
DISTINCTis not specified- there are no set-functions in the
SELECTlist (AVG,COUNT,MAX,MIN,SUM)- the
FROMclause specifies exactly one table reference and that table reference refers either to a base table or an updatable view- the result set is not the product of an explicit
INNERorOUTER JOIN- the
GROUP BYclause is not included- the
HAVINGclause is not included- the keyword
EXCEPTis not included- the keyword
INTERSECTis not included- the keyword
UNIONis not included- the
ORDER BYclause is not included- it is not the result of a call to a result set procedure.
A cursor which addresses a read-only result table may not be used for
DELETE CURRENTorUPDATE CURRENTstatements.Examples
SELECT format, category_id FROM formats ORDER BY LOWER(format), category_id; SELECT format AS format_name, category FROM formats ORDER BY CASE category WHEN 'ROCK' THEN 1 WHEN 'JAZZ' THEN 2 ELSE 3 END OFFSET 10 ROWS FETCH 5 ROWS ONLY;Standard Compliance
|
Mimer Information Technology AB Voice: +46 18 780 92 00 Fax: +46 18 780 92 40 info@mimer.se |
|
|