creating a function returning FALSE on NULL input ?

From: Yvon Thoraval <yvon(dot)thoraval(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: creating a function returning FALSE on NULL input ?
Date: 2012-11-07 05:33:15
Message-ID: CAG6bkBzTAnE1bWS8ChwJFbNtKb7vzkXTB0Ey2QB5p0gg=dsp3w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'd like to create a function :
returning true if the length of the text arg is greater than 0 ;
false otherwise ;

and also returning false when arg is NULL, then i wrote :

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

where i get the error :

ERROR: syntax error at or near "FALSE"
LINE 1: ...r_length($1) > 0;' LANGUAGE SQL IMMUTABLE RETURNS FALSE ON N...

with "RETURNS NULL on NULL INPUT", that's OK.

--
Yvon

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Yelai, Ramkumar IN BLR STS 2012-11-07 05:58:10 Re: Parallel Insert and Delete operation
Previous Message Bryan Montgomery 2012-11-07 05:29:39 Re: Tuning / performance questions