From: | Bricklen Anderson <banderson(at)presinet(dot)com> |
---|---|
To: | "Sistemas C(dot)M(dot)P(dot)" <sistemascmp(at)redynet4(dot)com(dot)ar> |
Cc: | pgsql-admin(at)postgresql(dot)org |
Subject: | Re: IsDate function in plpgsql |
Date: | 2006-04-27 14:40:24 |
Message-ID: | 4450D7D8.6050200@presinet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
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;
From | Date | Subject | |
---|---|---|---|
Next Message | Benjamin Krajmalnik | 2006-04-27 15:15:43 | Re: New system recommendations |
Previous Message | Ketema Harris | 2006-04-27 14:38:56 | Re: IsDate function in plpgsql |