Subject Re: [ib-support] using concatenator operator with nulls
Author Svein Erling Tysvaer
Hi again, Jordi!

Null is a state meaning that you do not know the value of the field and if
you do not know the value of the field, then you cannot know the value of
that field concatenated with another field.

The best thing would probably be to use an empty string rather than null -
at least if you mean that the field have no value as opposed to unknown.
Otherwise, you would have to do something like

select f1 || f2 from table
where f1 is not null and f2 is not null
union
select f1 from table
where f1 is not null and f2 is null
union
select f2 from table
where f1 is null and f2 is not null

to obtain what you want. Maybe you would also have to cast f1 and f2 in the
last two selects to a char of the appropriate length - I do not know.
Thinking about it, I think there is a NVL (or similar) function in a UDF
library possibly making it possible for you to simply use

select NVL(f1) || NVL(f2) from table

I've never used this, so others will have to tell you how to use it.

See you in Fulda in just over a week,
Set

At 14:47 09.05.2003 +0200, you wrote:
>Hi list,
>
>suppose I have two fields f1 and f2, of varchar type that can have null
>values. If I make a query like:
>
> select f1 || f2 from table
>
>the records where f1 is not null and f2 is null, the result is null, but I
>want the result to be f1 (the field which is not null).
>
>How can I make this? The Interbase documentation doesn't explain this.