Here is what I am trying to do. I have a table with two fields, both of which are supposed to contain a serial number. The first one is the primary key and is setup to default to a sequence in the normal way. The second one can be one of any number of sequences. The sequence to use is calculated at run time and the next sequence is manually included (creating the sequence if necessary.) Sometimes the sequence is left null. In those cases it is supposed to use the first (primary) field.
I suppose I can add a rule on the select but this is a huge and busy table with an index and selects on the second field. I would prefer if I could create the actual value value during insert. I did try this: ALTER TABLE certificate ALTER COLUMN card_id SET DEFAULT CURRVAL('certificate_certificate_id_seq'); This mostly works but it has two problems. The first is that it seems klugey and I am not sure if I can depend on it happening in the correct order. The second problem is that there are edge cases (albeit none that I can imagine happening in our application) that causes it to either fail or put a previous value into the field. Is there a better way to do what I am trying to do? -- D'Arcy J.M. Cain <[EMAIL PROTECTED]|vex}.net> | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly