Subject Re: what is wrong in this select?
Author danyschaer
Hi Fidel,

Thank you very much for answering me.

I forget to say I am testing with Firebird 2.1.

I know my sintaxis are not the best, and it is because they are self-
created by our query program, who need to build all together a lot of
filters una just one select expresion; also, my sintaxis has to run
exactly the same with Oracle, PostgreSQL and Firebird.

So I realy thank all of you that tries to give me better sitaxis (and
sure they are better!!!), but I only want to know if I am writting
legal expressions that can return the right rows, and if not, how can
I know what is worng, because Firebird error message is not so clear
to me (please see below).

It sounds me that this is legal. On the first input, I sent a shor
part of the real one, to make it ease for all. But the real one is
the next:

SELECT "PROC"."PROC",
"PROC"."EXP1" AS "EXPE",
"PROC"."ACTO",
"PROC"."DEMA",
"PROC"."OBSE",
"TPRO"."DSCR" AS "D_TPRO"
FROM "PROC" LEFT
OUTER JOIN "TPRO" ON "PROC"."TPRO" = "TPRO"."TPRO"
WHERE((EXISTS
(SELECT DISTINCT "PROC"
FROM(
(SELECT "ESTA"."PROC" FROM "ESTA" WHERE "ESTA"."TEST"
= '0002tem3IL')
UNION
(SELECT "ESTA"."PROC" FROM "ESTA" WHERE "ESTA"."TEST"
= '0002tKr&uQ')) t
WHERE t."PROC" = "PROC"."PROC")
)
)
ORDER BY LOWER("PROC"."ACTO")

And when I run it, Firebird says:

SQL Message : -104
Invalid token
Engine Code : 335544569
Engine Message :
Dynamic SQL Error
SQL error code = -104
Token unknown - line 13, column 6
UNION

At least, I think there is a problem when Firebird check the
expressions, because it reports me "UNION" as an unknow token, when
it is knwon.

I want to know, if possible, what is ilegal in my sintaxis.

Thans in advanced !!!

Dany