Subject Re: [firebird-support] what is wrong in this select?
Author Svein Erling Tysvaer
This is a question that I have no idea where should be asked, it fits
neither here nor in firebird-devel. But the answer is simple (since I
already have your database, it was a simple case of cut and paste to try
for myself), just remove some parenthesis.

select * from
(select "ESTA"."PROC" from "ESTA" where "ESTA"."TEST" = '0002tem3IL'
union
select "ESTA"."PROC" from "ESTA" where "ESTA"."TEST" = '0002tKr&uQ')

prepares and executes without problems. I have no idea whether this is
as designed or not, but I do not think the error message was too
informative, in my opinion it would be better if the error message had
been equal to the one displayed if you try
(select "ESTA"."PROC" from "ESTA" where "ESTA"."TEST" = '0002tem3IL'
union
select "ESTA"."PROC" from "ESTA" where "ESTA"."TEST" = '0002tKr&uQ')

Set

danyschaer wrote:
> Hi All,
>
> Maybe one of you can tell me what is wrong it this sintaxis:
>
> select * from (
> (select "ESTA"."PROC" from "ESTA" where "ESTA"."TEST" = '0002tem3IL')
> union
> (select "ESTA"."PROC" from "ESTA" where "ESTA"."TEST" = '0002tKr&uQ')
> )
>
> It works very well in other engines, but with Firebird, I get:
>
> Starting transaction...
> Preparing query: select * from (
> (select "ESTA"."PROC" from "ESTA" where "ESTA"."TEST" = '0002tem3IL')
> union
> (select "ESTA"."PROC" from "ESTA" where "ESTA"."TEST" = '0002tKr&uQ')
> )
> *** IBPP::SQLException ***
> Context: Statement::Prepare( select * from (
> (select "ESTA"."PROC" from "ESTA" where "ESTA"."TEST" = '0002tem3IL')
> union
> (select "ESTA"."PROC" from "ESTA" where "ESTA"."TEST" = '0002tKr&uQ')
> ) )
> Message: isc_dsql_prepare failed
>
> SQL Message : -104
> Invalid token
>
> Engine Code : 335544569
> Engine Message :
> Dynamic SQL Error
> SQL error code = -104
> Token unknown - line 3, column 1
> union
>
>
> Execute time: 00:00:00.
>
> It does not make sense to me that "union" is an unknown token.
>
> Thank you!
>
> Dany