From: chester c young <chestercyoung@yahoo.com>
To: sql pgsql <pgsql-sql@postgresql.org>
Subject: Re: data dependent sequences?
Date: Sun, 15 Jul 2007 09:07:05 -0700 (PDT)
Message-ID: <609880.51564.qm@web54306.mail.re2.yahoo.com> (raw)
In-Reply-To: <AKEFJAHAPDBEDKIICNJKMEJPCDAA.smcg2297@frii.com>
>
> 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
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: chestercyoung@yahoo.com
Subject: Re: data dependent sequences?
In-Reply-To: <609880.51564.qm@web54306.mail.re2.yahoo.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