| From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> | 
|---|---|
| To: | Domingo Alvarez Duarte <domingo(at)dad-it(dot)com> | 
| Cc: | pgsql-sql(at)postgresql(dot)org | 
| Subject: | Re: unique index on more than one field using functions | 
| Date: | 2001-07-23 17:49:52 | 
| Message-ID: | Pine.BSF.4.21.0107231047540.55137-100000@megazone23.bigpanda.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-sql | 
On 22 Jul 2001, Domingo Alvarez Duarte wrote:
> I'm trying create a unique index using more than one field and
> applying a function in one field to achieve case insensitive
> uniqueness but postgresql doesn't accept. 
> 
> create table a( 
> 
>   id int primary key,
>   id2 int not null,
>   name varchar(50),
>   unique(id2, lower(name))
>   );
> 
> Anyone have an idea ?
IIRC, Functional indexes are constrained to a single function
with one or more column references (no constants, etc), so
you can't precisely do the above directly.  You might be
able to make a function which takes id2 and name and combines
them in some way returning a single varchar and make the unique
index on that result.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dorin Grunberg | 2001-07-23 17:58:52 | Re: position(text,text) function | 
| Previous Message | dado feigenblatt | 2001-07-23 17:10:42 | Re: Get the tables names? |