Re: creating a function returning FALSE on NULL input ?

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: Yvon Thoraval <yvon(dot)thoraval(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: creating a function returning FALSE on NULL input ?
Date: 2012-11-07 07:43:42
Message-ID: 1617B66F-C96C-413A-9ECF-89379776130F@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 FALSE ON 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Yvon Thoraval 2012-11-07 07:57:45 Re: creating a function returning FALSE on NULL input ?
Previous Message Tianyin Xu 2012-11-07 07:37:39 The bug reporting form are unavailable