Re: [HACKERS] lower() not working correctly...?

From: Ragnar <gnari(at)hive(dot)is>
To: Andreas Joseph Krogh <andreak(at)officenet(dot)no>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [HACKERS] lower() not working correctly...?
Date: 2006-09-15 10:07:05
Message-ID: 1158314825.17224.190.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

On fös, 2006-09-15 at 09:52 +0200, Andreas Joseph Krogh wrote:
> I have the following query:
>
> select lower(firstname) || ' ' || lower(lastname) from person
>
> firstname and lastname are VARCHAR
>
> lower() returns NULL when firstname OR lastname is NULL, is this correct?

In fact, your problem has nothing to do with lower().

You probably did not expect the || operator
to return NULL when any of the operands is NULL

as seen in
select firstname || ' ' || lastname from person

so , as someone else has already mentioned,
you should use coalesce.

gnari

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-09-15 10:07:43 Re: Fixed length data types issue
Previous Message Martijn van Oosterhout 2006-09-15 09:40:55 Re: [ADMIN] Vacuum error on database postgres

Browse pgsql-sql by date

  From Date Subject
Next Message Markus Schaber 2006-09-15 14:41:09 Re: Aggregates with internal state type?
Previous Message A. Kretschmer 2006-09-15 09:36:24 Re: Omission of 'FROM' ? diff between pgsql 7.4.1 and pgsql 8.1.4