Is the use of CURRVAL in this example reliable in heavy use? CREATE TABLE users ( id SERIAL NOT NULL, email VARCHAR(24) DEFAULT NULL, PRIMARY KEY (id) ); CREATE TABLE users_with_email ( id INTEGER NOT NULL ); CREATE RULE add_email AS ON INSERT TO users WHERE (NEW.email IS NULL) DO INSERT INTO users_with_email (id) VALUES (CURRVAL('users_id_seq'));
I tried... CREATE RULE add_email AS ON INSERT TO users WHERE (NEW.email IS NULL) DO INSERT INTO users_with_email (id) VALUES (NEW.id); which was incrementing the sequence twice. Should I be using a trigger instead? This rule seems quite simple and easy enough... if reliable. - Nick -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers