pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ben K. <bkim@coe.tamu.edu>
To: pgsql-admin@postgresql.org
Subject: Re: How to enforce the use of the sequence for serial columns
Date: Thu, 14 Dec 2006 05:57:57 -0600 (CST)
Message-ID: <Pine.GSO.4.64.0612140543270.20249@coe.tamu.edu> (raw)



> create table mytable (myid serial primary key constraint 
mytable_myid_chk check 
(myid = currval('mytable_myid_seq'), mydata varchar(255), ...);


I'd like to clarify that this will not be a full solution, since it will 
not allow update of the table unless nextval has been used in the same 
sequence already.

There seems to be a hack in case of oracle that allows using currval 
without nextval, but it's a hack and I don't know if there's an equivalent 
in postgresql (http://rootshell.be/~yong321/computer/sequence.txt). 
(Oracle seems to have "disable" option when adding check constraint by 
alter table, but the context seem a bit different from ours so may not be 
useful in our case, at any rate.)




Regards

Ben K.
Developer
http://benix.tamu.edu




---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster



view thread (9+ messages)  latest in thread

Message-ID: <Pine.GSO.4.64.0612140543270.20249@coe.tamu.edu>
Permalink:  ../Pine.GSO.4.64.0612140543270.20249@coe.tamu.edu/
Also on:    postgresql.org/message-id/Pine.GSO.4.64.0612140543270.20249@coe.tamu.edu

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: bkim@coe.tamu.edu
  Subject: Re: How to enforce the use of the sequence for serial columns
  In-Reply-To: <Pine.GSO.4.64.0612140543270.20249@coe.tamu.edu>
  References: <Pine.GSO.4.64.0612140543270.20249@coe.tamu.edu>

* 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