| From: | Yvon Thoraval <yvon(dot)thoraval(at)gmail(dot)com> |
|---|---|
| To: | Alban Hertroys <haramrae(at)gmail(dot)com> |
| Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: creating a function returning FALSE on NULL input ? |
| Date: | 2012-11-07 07:57:45 |
| Message-ID: | CAG6bkBz_p1=OYe=y+zi8kyZRptjKyeCg4PgN9VZMV+o6GTdd2w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Fine, thanks it's shorter than mine and works too.
I'll adopt it ))
2012/11/7 Alban Hertroys <haramrae(at)gmail(dot)com>
> 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.
>
>
--
Yvon
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Achilleas Mantzios | 2012-11-07 08:16:43 | Re: Memory issue on FreeBSD |
| Previous Message | Alban Hertroys | 2012-11-07 07:43:42 | Re: creating a function returning FALSE on NULL input ? |