Search Postgresql Archives

Re: Trouble with NEW

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/19/2012 08:41 AM, Bob Pawley wrote:
In all my reading of new and old I never made that connection.

It makes more sense if you know what NEW and OLD represent.

What follows is a simplification:
1)Postgres uses Multiversion Concurrency Control(MVCC). See here for brief intro:
http://www.postgresql.org/docs/9.0/interactive/mvcc-intro.html

2) As a result on:
A) INSERT. For each record you have only a corresponding NEW record that holds the values you are inserting. b) UPDATE. In Postgres an update is a two part process where you delete the old record and insert the new record. In that case you have both an OLD and a NEW record representing the respective values. c) DELETE. You are getting rid of a record and all you have is the OLD record representing the record you are deleting.

3) When you use a trigger or rule that uses the OLD, NEW records it only has access to those records for the table it is attached to.

4) If you want to pull information from another table, you either need to set up a FOREIGN KEY relationship that you can leverage or you need to do a query in the trigger function that pulls in the necessary information.


Thanks Adrian

Bob




--
Adrian Klaver
adrian.klaver@xxxxxxxxx



--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux