INSERT INTO db(a,b) VALUES (key, data);
RETURN;
EXCEPTION WHEN unique_violation THEN
- -- do nothing, and loop to try the UPDATE again
+ -- Do nothing, and loop to try the UPDATE again.
END;
END LOOP;
END;
SELECT merge_db(1, 'david');
SELECT merge_db(1, 'dennis');
-
+ This example assumes the unique_violation> error is caused by
+ the INSERT>, and not by an INSERT> trigger function
+ on the table. Also, this example only works in the default Read
+ Committed transaction mode.