AW: Possible feature?

Поиск
Список
Период
Сортировка
Искать

AW: Possible feature?

От:
Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at>
Дата:

> Then, when the UNIQUE constraint of the index is violated, instead of
> the message:
> 
> 'Cannot insert a duplicate key into a unique index i_test1'
> 
> the client application would receive:
> 
> 'An employee with a matching Social Security number already exists'

I would only allow this text to be output in addition to the standard
text. Else confusion would imho be too great for the unwary admin.

Thus following would be returned:
ERROR 03005 'Cannot insert a duplicate key into a unique index i_test1'
DESCRIPTION 'An employee with a matching Social Security number already exists'

On the other hand, what hinders you from using a "speaking" name for the 
constraint ?

postgres=# create table aa (id int, constraint "for Social Security number" unique (id));
NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'for Social Security number' for table 'aa'
CREATE
postgres=# insert into aa values (1);
INSERT 23741 1
postgres=# insert into aa values (1);
ERROR:  Cannot insert a duplicate key into unique index for Social Security number
postgres=#  :-O

Andreas

Re: AW: Possible feature?

От:
Hannu Krosing <hannu@tm.ee>
Дата:
Zeugswetter Andreas SB wrote:
> 
> On the other hand, what hinders you from using a "speaking" name for the
> constraint ?
> 
> postgres=# create table aa (id int, constraint "for Social Security number" unique (id));
> NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'for Social Security number' for table 'aa'
> CREATE
> postgres=# insert into aa values (1);
> INSERT 23741 1
> postgres=# insert into aa values (1);
> ERROR:  Cannot insert a duplicate key into unique index for Social Security number

I might want the message to be in some other language ...

I might even want the language to depend on CURRENT_USER.

-------------
Hannu

FAQ