From sistemascmp@redynet4.com.ar Thu Apr 27 14:32:38 2006 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 8E6EE11F6278 for ; Thu, 27 Apr 2006 11:32:38 -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 33180-07 for ; Thu, 27 Apr 2006 11:32:30 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from joyin.redynet.com.ar (smtp.redynet.com.ar [200.69.11.15]) by postgresql.org (Postfix) with SMTP id 8DEC111F60BF for ; Thu, 27 Apr 2006 11:32:26 -0300 (ADT) Received: (qmail 5772 invoked by uid 82); 27 Apr 2006 14:47:21 -0000 Received: from unknown (HELO pcsistemas) (200.69.8.40) by smtp.redynet.com.ar with SMTP; 27 Apr 2006 14:47:21 -0000 Message-ID: <006501c66a07$b8c08d60$0501a8c0@pcsistemas> From: "Sistemas C.M.P." To: Subject: IsDate function in plpgsql Date: Thu, 27 Apr 2006 11:34:42 -0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0062_01C669EE.9351C3A0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/305 X-Sequence-Number: 21474 This is a multi-part message in MIME format. ------=_NextPart_000_0062_01C669EE.9351C3A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable A few days ago, someone in this list gives me a function (plpgsql) that = evaluates if a string is a valid date or not.=20 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.=20 This is the function begin perform $1::date; return 1; exception when others then return 0; end ------=_NextPart_000_0062_01C669EE.9351C3A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
A few days ago, someone in this=20 list gives  me a function (plpgsql) that evaluates if a string = is a=20 valid date or not.
It returns 1 or 0 (valid/Not = Valid)
The problem is that if the argument is = a NULL field=20 the function returns 1.
I don't have experience with plpgsql = language.=20
This is the function
 
begin
  perform = $1::date;
  return 1;
exception when others then
  = return=20 0;
end
------=_NextPart_000_0062_01C669EE.9351C3A0-- From ketema@gmail.com Thu Apr 27 14:39:09 2006 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-- From banderson@presinet.com Thu Apr 27 14:40:12 2006 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;