Re: [HACKERS] lower() not working correctly...? - Mailing list pgsql-sql

From Ragnar
Subject Re: [HACKERS] lower() not working correctly...?
Date
Msg-id 1158314825.17224.190.camel@localhost.localdomain
Whole thread Raw
List 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




pgsql-sql by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: Omission of 'FROM' ? diff between pgsql 7.4.1 and pgsql 8.1.4
Next
From: Markus Schaber
Date:
Subject: Re: Aggregates with internal state type?