Syntax
The SELECT (embedded) statement has the following format:
Non-cursor version:
EXEC SQL [REPEATED] SELECT [ALLl | DISTINCT]
* | result_expression{, result_expression}
INTO variable[:indicator_var] {, variable[:indicator_var]}
[FROM from_source {, from_source}
[WHERE search_condition]
[GROUP BY column {, column}]
[HAVING search_condition]]
[UNION [ALL] full_select]
[ORDER BY result_column [ASC | DESC]
{, result_column [ASC | DESC]}]
[EXEC SQL BEGIN;
program code;
EXEC SQL END;]
Cursor version (embedded in a DECLARE CURSOR statement):
SELECT [ALL|DISTINCT]
* | result_expression {, result_expression}
[FROM from_source {, from_source}
[WHERE search_condition]
[GROUP BY column {, column}]
[HAVING search_condition]
[UNION [ALL] full_select]
[ORDER BY result_column [ASC|DESC]
{, result_column [ASC|DESC]}]
where result_expression is one of the following:
• [schema.]table_name.*
Selects all columns
• [[schema.]table_name.]column_name AS result_column
Selects one column
• expression AS result_column