Re: Reducing duplicated business rules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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.



[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux