Re: creating a function returning FALSE on NULL input ? - Mailing list pgsql-general

From Alban Hertroys
Subject Re: creating a function returning FALSE on NULL input ?
Date
Msg-id 1617B66F-C96C-413A-9ECF-89379776130F@gmail.com
Whole thread Raw
In response to creating a function returning FALSE on NULL input ?  (Yvon Thoraval <yvon.thoraval@gmail.com>)
Responses Re: creating a function returning FALSE on NULL input ?  (Yvon Thoraval <yvon.thoraval@gmail.com>)
List pgsql-general
On 7 Nov 2012, at 6:33, Yvon Thoraval wrote:

> CREATE FUNCTION has_infos(text) RETURNS boolean AS 'select character_length($1) > 0;' LANGUAGE SQL IMMUTABLE RETURNS
FALSEON NULL INPUT; 

Try:
CREATE FUNCTION has_infos(text) RETURNS boolean AS 'select coalesce(character_length($1) > 0, false);' LANGUAGE SQL
IMMUTABLE;

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.



pgsql-general by date:

Previous
From: Tianyin Xu
Date:
Subject: The bug reporting form are unavailable
Next
From: Yvon Thoraval
Date:
Subject: Re: creating a function returning FALSE on NULL input ?