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 8F87711F6262 for ; Thu, 27 Apr 2006 11:39:09 -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 32240-10 for ; Thu, 27 Apr 2006 11:39:00 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.225]) by postgresql.org (Postfix) with ESMTP id B10E511F60BF for ; Thu, 27 Apr 2006 11:38:58 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id i32so1610214wra for ; Thu, 27 Apr 2006 07:38:59 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:user-agent:date:subject:from:to:message-id:thread-topic:thread-index:in-reply-to:mime-version:content-type; b=OqOb0NkBW75DYBDS8gQAJUikYkgDi5ty1FRqeOZ6Uda1RJymRanb0J3Ce5cQr++MRwEi1cwSiQZ/gBw95UT2V3cqDoBv6ZarooHzp7vSx5b3vR804F3p8BSlcf+esGinyxOz+xW3HJd/zwxq+yh815GGfQzvVM1cCLzAHjQ3yR0= Received: by 10.54.110.5 with SMTP id i5mr8277314wrc; Thu, 27 Apr 2006 07:38:58 -0700 (PDT) Received: from ?192.168.0.12? ( [72.156.236.193]) by mx.gmail.com with ESMTP id 12sm914336wrl.2006.04.27.07.38.57; Thu, 27 Apr 2006 07:38:58 -0700 (PDT) User-Agent: Microsoft-Entourage/11.2.3.060209 Date: Thu, 27 Apr 2006 10:38:56 -0400 Subject: Re: IsDate function in plpgsql From: Ketema Harris To: "Sistemas C.M.P." , Message-ID: Thread-Topic: [ADMIN] IsDate function in plpgsql Thread-Index: AcZqCE/vjsApM9X7Edqi1AARJHlfcA== In-Reply-To: <006501c66a07$b8c08d60$0501a8c0@pcsistemas> Mime-version: 1.0 Content-type: multipart/alternative; boundary="B_3228979137_498184" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/306 X-Sequence-Number: 21475 > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --B_3228979137_498184 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit I think someone will show you a better way, but if all you need to do is account for the NULLS... begin if $1 is null then return 0; else perform $1::date; return 1; end if; exception when others then return 0; end On 4/27/06 10:34 AM, "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 > --B_3228979137_498184 Content-type: text/html; charset="US-ASCII" Content-transfer-encoding: quoted-printable Re: [ADMIN] IsDate function in plpgsql I think someone will s= how you a better way, but if all you need to do is account for the NULLS...<= BR>
begin
  if $1 is null then
     return 0;
  else
     perform $1::date;
     return 1;
  end if;
exception when others then
return 0;
end


On 4/27/06 10:34 AM, "Sistemas C.M.P." <sistemascmp@redynet4.c= om.ar> wrote:

A few days ago, someone in this list gives  me a function (plpgsql) th= at 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


--B_3228979137_498184--