Re: Reducing duplicated business rules - Mailing list pgsql-php

From Michael Glaesemann
Subject Re: Reducing duplicated business rules
Date
Msg-id 714126A2-1082-11D8-B410-0005029FC1A7@myrealbox.com
Whole thread Raw
In response to Re: Reducing duplicated business rules  (Daniel Struck <struck.d@retrovirology.lu>)
Responses Re: Reducing duplicated business rules
List pgsql-php
Hi Daniel,

On Friday, November 7, 2003, at 12:52 AM, Daniel Struck wrote:

>> Of course PostgreSQL will throw back an error if I tried to insert or
>> update data that will make the check constraint untrue
>
> I thought about using named constraints:
<snip/>
> CONSTRAINT "!!!#Please check XYZ in the formular#" CHECK ([whatever
> you like to test])
> );
>
> Next, I would check in php if an error occured in the sql-query, if
> the error includes "!!!" in the error message from postgresql I would
> display the formular again with the values already entered and I would
> display as a feedback to the user the string between the two "##":

Interesting idea. Then you can include more specific information rather
than just the PostgreSQL error. I wonder if there wouldn't be a way to
use COMMENT information on the constraint as well—grab the COMMENT for
whatever named constraint caused it to fail.

> One drawback is of course that it will only give feedback from one
> error at a time.

I don't know if this is the best way to do this, but it might be
workable in the short term. It would be nice to be able to ask the
database, in effect "Okay, yeah, that's not a good piece of data. But
let's assume that part were okay. Any other problems? Besides that?"
Then you could possibly get more feedback from the database.


pgsql-php by date:

Previous
From: Michael Glaesemann
Date:
Subject: Re: Reducing duplicated business rules
Next
From: Bruno Wolff III
Date:
Subject: Re: Reducing duplicated business rules