Subject Re: [firebird-support] Possible UNION problem in CREATE VIEW
Author Dimitry Sibiryakov
> CREATE VIEW INFORMATION_SCHEMA_TABLES AS
> SELECT DISTINCT NULL AS TABLE_CATALOG , NULL AS TABLE_SCHEMA ,RDB$RELATION_NAME AS TABLE_NAME, 'BASE TABLE' AS TABLE_TYPE
> FROM RDB$RELATION_FIELDS
> WHERE RDB$SYSTEM_FLAG=0 AND RDB$VIEW_CONTEXT IS NULL
> UNION
> SELECT DISTINCT NULL AS TABLE_CATALOG , NULL AS TABLE_SCHEMA ,RDB$RELATION_NAME AS TABLE_NAME, 'VIEW' AS TABLE_TYPE
> FROM RDB$RELATION_FIELDS
> WHERE RDB$SYSTEM_FLAG=0 AND RDB$VIEW_CONTEXT IS NOT NULL;
>
> The view will fail with the following error:
>
> SQL Error.
> SQL error code = -607.
> Invalid command.
> must specify column name for view select expression.
>
> Interestingly, when I create the view using the syntax upto and immediately before the UNION statement, it works correctly.
>
> Am I missing something, or is there an issue regarding the use of the UNION keyword in the CREATE VIEW statement?
>
> Any help would be greatly apprecaited, as this is driving me nuts.

Which word in "must specify column name for view select expression"
is not clear to you? Column names must be declared in parentheses right
after view name.

SY, SD.