Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id D66329FA299 for ; Tue, 17 Jul 2007 10:40:15 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 76246-07 for ; Tue, 17 Jul 2007 10:40:04 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id 4369C9FB458 for ; Tue, 17 Jul 2007 10:40:04 -0300 (ADT) Received: from root by ciao.gmane.org with local (Exim 4.43) id 1IAnHW-0005wl-FR for pgsql-sql@postgresql.org; Tue, 17 Jul 2007 15:40:02 +0200 Received: from smcgraw.ppp.frii.com ([216.17.133.158]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 17 Jul 2007 15:40:02 +0200 Received: from smcg2297 by smcgraw.ppp.frii.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 17 Jul 2007 15:40:02 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: "Stuart" Subject: Re: data dependent sequences? Date: Tue, 17 Jul 2007 07:34:44 -0600 Lines: 35 Message-ID: References: <609880.51564.qm@web54306.mail.re2.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: smcgraw.ppp.frii.com X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1896 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.115 tagged_above=0 required=5 tests=AWL=0.114, BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200707/99 X-Sequence-Number: 28834 "chester c young" wrote in message news:609880.51564.qm@web54306.mail.re2.yahoo.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 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.