Re: data dependent sequences?

From: chester c young <chestercyoung(at)yahoo(dot)com>
To: sql pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: data dependent sequences?
Date: 2007-07-15 16:07:05
Message-ID: 609880.51564.qm@web54306.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>
> CREATE TABLE items (
> id INT,
> typ INT ...
> PRIMAY KEY (seq,typ));
>

> id typ
> ----+-----
> 1 'a'
> 2 'a'
> 3 'a'
> 1 'b'
> 4 'a'
> 2 'b'
>

you will need to use pre insert trigger since you cannot use column
references in default expression.

you could use this same trigger to either:
- create sequences as needed and apply the right one
- with locking, lookup for last id of typ
- with locking, keep another table of typ and nextval


____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Dani Castaños 2007-07-16 11:06:21 Having the sum of two queries
Previous Message Ragnar 2007-07-15 16:04:56 Re: data dependent sequences?