On 2009-04-28, David <david@xxxxxxxxxxxxxxx> wrote: > Ok got permission to send the code I think I have got all the relevent bits. > >CREATE TABLE currentcall ( > cadc_taskno integer DEFAULT nextval(('currentcall_cadc_taskno_seq'::text)::regclass) NOT NULL, > coversight character varying(4), ... >CREATE RULE currentcall_insert AS ON INSERT TO currentcall DO INSERT INTO > taskchangelog (tasknum, newstatus, newtech, status, newpriority, > newestcomplete, newclass, newnewtask) VALUES (new.cadc_taskno, ^^^^^^^^^^^^^^^ > new.cstatus, new.ctechalloc, new.ccustcomment, new.cfprior, > new.cestcomplete, new.cjobclass, (new.cnewtask = 'Y'::bpchar)); if you're inserting DEFAULT into the cadc_taskno column (or not explicitly setting that column) the re-writer will substitute nextval(('currentcall_cadc_taskno_seq'::text)::regclass) And that will be evaluated once for the insert and again for the rule. this is documented somewhere.... I think -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general