Re: Reducing duplicated business rules

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: Re: Reducing duplicated business rules
Date: 2003-11-06 17:55:43
Message-ID: 714126A2-1082-11D8-B410-0005029FC1A7@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Bruno Wolff III 2003-11-06 19:20:38 Re: Reducing duplicated business rules
Previous Message Michael Glaesemann 2003-11-06 16:16:54 Re: Reducing duplicated business rules