Em 30/06/2012 10:02, Andrus escreveu:
Pardon for my intrusion, but my experience has demonstrated that the decision if an insert or update is necessary should be done at application level.
Users will get mad with application "magically" changing their data in a multiuser high concurrence environment.
Now, if your case is just the insert, then you can try something similar to
WITH upd AS (
UPDATE employees SET sales_count = sales_count + 1 WHERE id =
(SELECT sales_person FROM accounts WHERE name = 'Acme Corporation')
INSERT INTO employees_log SELECT *, current_timestamp FROM upd;
documentation page at http://www.postgresql.org/docs/9.1/static/sql-insert.html
Just my 2c.
[Postgresql Jobs] [Postgresql Admin] [Postgresql Performance] [Linux Clusters] [PHP Home] [PHP on Windows] [Programming PHP] [Kernel Newbies] [PHP Classes] [Find Someone Nice] [PHP Books] [PHP Databases] [Postgresql & PHP] [Yosemite]