Re: data dependent sequences?

From: "Stuart" <smcg2297(at)frii(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: data dependent sequences?
Date: 2007-07-17 13:34:44
Message-ID: f7ighl$1pv$1@sea.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"chester c young" <chestercyoung(at)yahoo(dot)com> wrote in message news:609880(dot)51564(dot)qm(at)web54306(dot)mail(dot)re2(dot)yahoo(dot)com(dot)(dot)(dot)
> >
> > 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

Thanks, that summerizes the options nicely.

I noticed that sequences are tables with a single row
that defines the sequence properties. I was hoping
that there was some way of using a sequence with multiple
rows to maintain multiplre sequences in a sngle table,
which would make having a large number of sequences a
little less cluttered, but sounds like I need to implement
that from scratch.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Broersma Jr 2007-07-17 14:19:05 Re: data dependent sequences?
Previous Message Stuart 2007-07-17 13:34:26 Re: data dependent sequences?