pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Yeb Havinga <yebhavinga@gmail.com>
To: Andreas <maps.on@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Howto have a unique restraint on UPPER (textfield)
Date: Fri, 05 Feb 2010 21:57:10 +0100
Message-ID: <4B6C8626.6080300@gmail.com> (raw)
In-Reply-To: <4B64EA46.60605@gmx.net>
References: <4B64EA46.60605@gmx.net>

Andreas wrote:
> is there a way to define a unique restraint on UPPER (textfield)?
> psql throws a syntax error because of the upper() function.
The third section of the create index command at 
http://www.postgresql.org/docs/8.4/interactive/sql-createindex.html 
describes a function based index with as example the function .... 
upper! :-)

postgres=# create table aap (a text);
CREATE TABLE
postgres=# create unique index ai on aap (upper(a));
CREATE INDEX
postgres=# insert into aap values ('aap');
INSERT 0 1
postgres=# insert into aap values ('aaP');
ERROR:  duplicate key value violates unique constraint "ai"

regards,
Yeb Havinga





view thread (8+ messages)

Message-ID: <4B6C8626.6080300@gmail.com>
Permalink:  ../4B6C8626.6080300@gmail.com/
Also on:    postgresql.org/message-id/4B6C8626.6080300@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: yebhavinga@gmail.com, maps.on@gmx.net
  Subject: Re: Howto have a unique restraint on UPPER (textfield)
  In-Reply-To: <4B6C8626.6080300@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox