X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 9087111F6276 for ; Thu, 27 Apr 2006 11:40:12 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 38724-01-2 for ; Thu, 27 Apr 2006 11:40:03 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from presinet.com (mail.presinet.com [209.53.156.1]) by postgresql.org (Postfix) with ESMTP id 9D7BC11F6262 for ; Thu, 27 Apr 2006 11:40:00 -0300 (ADT) Received: from [10.10.1.151] ([10.10.1.151]) by presinet.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 27 Apr 2006 07:38:01 -0700 Message-ID: <4450D7D8.6050200@presinet.com> Date: Thu, 27 Apr 2006 07:40:24 -0700 From: Bricklen Anderson User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051013) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Sistemas C.M.P." CC: pgsql-admin@postgresql.org Subject: Re: IsDate function in plpgsql References: <006501c66a07$b8c08d60$0501a8c0@pcsistemas> In-Reply-To: <006501c66a07$b8c08d60$0501a8c0@pcsistemas> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 27 Apr 2006 14:38:01.0890 (UTC) FILETIME=[2FAEB820:01C66A08] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/307 X-Sequence-Number: 21476 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;