Subject Re: [firebird-support] Data type unknown....
Author Helen Borrie
Ryan,

At 04:08 AM 3/06/2005 +0000, you wrote:
>I've scanned through the news groups for a hint as to what I'm doing
>wrong but I can't for the life of me figure it out.
>
>Here is my SQL statement:
>
>select
> loc.locationname,
> pg.programgroupindex,
> pg.programgroupname,
> prog.programname
>
>from locations loc
> join programgroups pg on pg.locationid = loc.locationid
> join programs prog on prog.programgroupid = pg.programgroupid
>
>where loc.locationid=8
>
>union all
>
>select
> loc.locationname,
> cast(-1 as integer) a,
> cast('' as varchar(64)) b,
> nonprog.nonprogramstat
>
>from locations loc
> join nonprograms nonprog on nonprog.locationid = loc.locationid
>
>where loc.locationid=8
>
>order by
> 2, 3, 4
>
>I found the CAST statement trick as posted earlier by Helen, but for
>some reason I'm still getting the error message Data type unknown.
>
>Why is that?
>
>Even if I modify the statement to only include the first two columns I
>still get the error message.
>
>Any insight would be great...
>
>I'm running FB 1.5.2

Bear in mind that the structure of the entire query is determined by the
structure of the first SELECT. Two things to watch here:

1) Don't use alias names in any of the selects except the first one. In
this example, you don't need alias names at all because the set is being
defined (in the first SELECT) by genuine columns, not expressions

2) Double check that the castings you are using are compatible with the
column definitions of the first SELECT. If you are confused as to what is
or isn't compatible, then cast the expression fields in the subsequent
selects to the exact data types of the corresponding columns in the first
SELECT.

./heLen