Anyone? Please On Jul 31, 12:36 pm, Nick <nboutel...@xxxxxxxxx> wrote: > If I insert a duplicate row into a table, id like to return the > existing key. > > I tried creating a rule for this... > > CREATE RULE no_duplicates AS ON INSERT TO names WHERE EXISTS (SELECT 1 > FROM names WHERE new.name = name) DO INSTEAD SELECT id, name FROM > names WHERE name = new.name; > > However, I get an error on... > > INSERT INTO names (name) VALUES ('existing') RETURNING *; > > ERROR: cannot perform INSERT RETURNING on relation "names" > HINT: You need an unconditional ON INSERT DO INSTEAD rule with a > RETURNING clause. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general