Re: getting details about integrity constraint violation

From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Cc: twanger(at)bluetwanger(dot)de
Subject: Re: getting details about integrity constraint violation
Date: 2005-06-15 02:06:20
Message-ID: 93b83a5f4f948719c40b2ecac346c692@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>> Simply name the table constraints yourself with a descriptive name, so you
>> always know exactly what is going on:

> And then I keep a list of all the constraint names and scan the error
> message for it?

Don't keep a list: just come up with a standard naming scheme, such as:

"tablename|colname|is_not_unique"

which should be human and machine parseable (perl example):

if ($error =~ m#^(.+)\|(.+)\|is_not_unique$#o) {
die qq{Whoops : looks like column "$2" of table "$1" needs to be unique\n};
}

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200506142204
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iD8DBQFCr4zivJuQZxSWSsgRAgGPAJ0awkoBmus6z1cLBRpsR5xmQPTfiACgpJxG
Ld90hEGDPrebBE3JGGL11L4=
=smQJ
-----END PGP SIGNATURE-----

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Praveen Raja 2005-06-15 11:39:11 update syntax
Previous Message Igor Katrayev 2005-06-14 19:27:30 Re: Set Membership operator -- test group membership