Re: check date validity

From: Bill Gribble <grib(at)billgribble(dot)com>
To: Harald Fuchs <hf99(at)protecting(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: check date validity
Date: 2004-01-16 14:13:37
Message-ID: 1074262417.1334.9.camel@serrano
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 2004-01-16 at 06:58, Harald Fuchs wrote:
> In article <20040116054046(dot)E4E751C173283(at)smtp(dot)vip(dot)163(dot)com>,
> "LitelWang" <wlxyk(at)vip(dot)163(dot)com> writes:
> > I need this function :
> > CheckDate('2002-02-29') return false
> > CheckDate('2002-02-28') return true
>
> Why would you want to do that? Just try to insert '2002-02-29' into
> your DATE column, and PostgreSQL will complain.

But it won't complain usefully. It will just abort the transaction.
It's difficult to determine what went wrong when Postgres craps out,
which is at least in part why many on this list recommend duplicating
all the database validation logic in your application for EVERY type.

To me, this seems like a waste of effort, since both the application and
the DB server have to confirm that every date (for example, but applies
to every other type as well) is valid. But I can't see how to do it any
other way, since the prevailing consensus among the PG devs seems to be
that any problem with the values of data is an application problem, not
a database problem, so don't expect to get any help from the server
other than "Sorry, that transaction is now gone. Hope you can reproduce
the work! Have a nice day."

Thanks,
b.g.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ivar 2004-01-16 14:19:17 Re: Creating GUID
Previous Message David Garamond 2004-01-16 13:56:10 Re: Creating GUID