Application validation of data on insert

From: "John Cohorn" <elotemuygrande(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Application validation of data on insert
Date: 2006-12-31 22:27:33
Message-ID: fdc23ba20612311427u3fb69053u2b20b791f7b7bf6b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello!

I'm only moderately familiar with postgres and the DBI related modules that
I'm using to access it so forgive me if this is a simple question. I've been
looking for several hours for information on this and have not found a
satisfying answer.

I'm writing a simple CGI application to do simple create, update, delete
operations on a few tables and although doing these basic operations is
trivial I am having a great deal of trouble figuring out the best way to
validate data being inserted and handle related errors.

My question in a nutshell is when performing an INSERT, how do I determine
exactly which columns are responsible for the error when one occurs(so that
within the application I can say "hey user check how you typed field x,
field y). The SQLSTATUS error codes are very non-specific and I cannot find
another method for checking what failed without parsing text
output(unreasonable for many reasons). Perhaps there is a way to define an
INSERT trigger that could place/return the names of the problem columns
somewhere? Doing this in a way that does not tie one only to PGSQL(although
it's my favorite) is even more of a problem.

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.

Thanks for your enlightenment!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2006-12-31 22:39:24 Re: Installing support for python on windows
Previous Message novnov 2006-12-31 22:09:38 Installing support for python on windows