From: Bricklen Anderson <banderson@presinet.com>
To: Sistemas C.M.P. <sistemascmp@redynet4.com.ar>
Cc: pgsql-admin@postgresql.org
Subject: Re: IsDate function in plpgsql
Date: Thu, 27 Apr 2006 07:40:24 -0700
Message-ID: <4450D7D8.6050200@presinet.com> (raw)
In-Reply-To: <006501c66a07$b8c08d60$0501a8c0@pcsistemas>
References: <006501c66a07$b8c08d60$0501a8c0@pcsistemas>
Sistemas C.M.P. wrote:
> A few days ago, someone in this list gives me a function (plpgsql) that
> evaluates if a string is a valid date or not.
> It returns 1 or 0 (valid/Not Valid)
> The problem is that if the argument is a NULL field the function returns 1.
> I don't have experience with plpgsql language.
> This is the function
>
> begin
> perform $1::date;
> return 1;
> exception when others then
> return 0;
> end
create or replace function datetest (text) returns integer as $$
begin
if ($1 is null) then
return 0;
end if;
perform $1::date;
return 1;
exception when others then
return 0;
end;
$$ language plpgsql;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: banderson@presinet.com, sistemascmp@redynet4.com.ar
Subject: Re: IsDate function in plpgsql
In-Reply-To: <4450D7D8.6050200@presinet.com>
References: <006501c66a07$b8c08d60$0501a8c0@pcsistemas> <4450D7D8.6050200@presinet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox