Re: data dependent sequences? - Mailing list pgsql-sql

From chester c young
Subject Re: data dependent sequences?
Date
Msg-id 609880.51564.qm@web54306.mail.re2.yahoo.com
Whole thread Raw
In response to data dependent sequences?  ("Stuart McGraw" <smcg2297@frii.com>)
List 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


pgsql-sql by date:

Previous
From: Ragnar
Date:
Subject: Re: data dependent sequences?
Next
From: Dani Castaños
Date:
Subject: Having the sum of two queries