Subject Re: UNION
Author stanw1950
--- In IBObjects@yahoogroups.com, "Jonathan M. Freedman"
<jonathanmfreedman@h...> wrote:
> i have a query i am developing using the query component...it
> involves combining parts of two tables with a UNION command...the
> query builds and prepares when i UNION two tables, but when i add
the
> 3rd, it doesn't prepare...it gives me back an error message that i
> have an unknown data type. Both the query and the error message
are
> printed below...cbuilder 6 prof, firebird 1.5 rc7, ibo 4.3.A.a.,
> windows xp prof. How does one UNION 3 tables?
>
> tyia
>
> SELECT
> CH.NAM
> , CH.DOB
> , CH.REL
> , CH.CLNTFK
> , CH.HXCHILDPK
>
> FROM HXCHILD CH
> UNION
> SELECT
> SI.NAM
> , SI.DOB
> , SI.REL
> , SI.CLNTFK
> , SI.HXSIBSPK
> FROM HXSIBS SI
>
> UNION
>
> SELECT
> SP.NAM
> , SP.DOB
> , SP.REL
> , SP.CLNTFK
> , SP.HXSPOUSPK
> FROM HXSPOUS SP
>
> ---------------------------
> C++Builder 6
> ---------------------------
> ISC ERROR CODE:335544569
>
>
>
> ISC ERROR MESSAGE:
>
> Dynamic SQL Error
>
> SQL error code = -104
>
> Invalid command
>
> Data type unknown

This is really an sql problem and not an IBO problem but your query
should work. For all three tables make sure the data types are
exactly the same for each equivalent field. If they aren't, you'll
get a data type unknown error. Run the query outside of your program
in some management program to test it. Also, if the data from the
three tables don't overlap "union all" is suppose to be faster than
just "union".