Re: Application validation of data on insert

From: Richard Huxton <dev(at)archonet(dot)com>
To: John Cohorn <elotemuygrande(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Application validation of data on insert
Date: 2007-01-02 09:38:16
Message-ID: 459A2808.8090008@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

John Cohorn wrote:
> It seems to me that all information about acceptable values, constraints
> and
> types for columns is already present within the table definitions so
> duplicating those checks and definitions within the application and user
> view is folly.

Well, there I'd disagree with you. With a web-based application you
might typically have three levels of validation:
1. Javascript on the client side
2. Server-side validation
3. Database validation

The view of data at the application level might well be different from
that at the database level (if you insert data via a view or function
for example). Providing test/erros that mean something to the
application (and its users) is something that your application needs to
handle. Hopefully your application framework provides some help with
these tests.

But, you still want to extract the column-names etc. and I'm afraid that
will require parsing the error messages at present. There has been
discussion on returning more structured information in the error
packets, but that will mean a change in the communication protocol, so
won't ever apply to older versions of the database.

HTH
--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2007-01-02 09:39:16 Re: select union with table name
Previous Message Yesh 2007-01-02 05:21:33 About auto_increment