Subject Re: [firebird-support] do not work view (case)
Author Helen Borrie
At 08:31 AM 21/10/2007, you wrote:
>Hello,
>
>in table "order_" field "GroupCode_" change type of customer (hotel,
>restaurant etc). Each customer type have own table with its details.
>
>i created view:
>
>create view v_order_ (code_, ... ObjectName, ... Town, ... ObjectCode, GroupCode_) as
>select
> o.code_, ...
> case o.GroupCode_
> when '0' then null
> when '1' then h.thename
> when '2' then tr.name_
> when '3' then g.name_
> when '4' then tu.thename
> when '5' then r.thename
> end, ...
> case o.GroupCode_
> when '0' then null
> when '1' then h.town
> when '2' then tr.town
> when '3' then g.town
> when '4' then tu.town
> when '5' then r.town
> end, ...
> o.ObjectCode,
> o.GroupCode_
>from order_ o
>join hotel h on o.ObjectCode = h.code_
>join transport tr on o.ObjectCode = tr.code_
>join guide g on o.ObjectCode = g.code_
>join turfirm tu on o.ObjectCode = tu.code_
>join restaurant r on o.ObjectCode = r.code_;
>
>While every record has GroupCode_ = null - all is ok and view is
>working (ObjectName is null).
>
>But when in any record GroupCode_ != null view is showing nothing :(
>(in IBExpert it shows one record with all null fields)

Don't you need left joins to the lookup tables? Your query returns results only where ALL of the inner joins have matches, otherwise nothing.

./heLen