Re: [GENERAL] On insert duplicate row, return existing key

2010-08-05 Thread Craig Ringer
On 05/08/10 06:03, Nick wrote: > Anyone? Please It's probably going to be a lot easier to do this with a stored procedure. I don't rate your chances of making it work with a rule. Rules work more like a macro system, and I'm not sure they can be convinced to do what you're trying to do. -- Craig

Re: [GENERAL] On insert duplicate row, return existing key

2010-08-04 Thread Nick
Anyone? Please On Jul 31, 12:36 pm, Nick 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 SELEC