pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Servin <cservin@cromagnon.com>
To: pgsql-sql@postgresql.org
Subject: Statement Triggers and access to other rows in the transaction
Date: Wed, 1 Nov 2006 10:50:33 -0600
Message-ID: <200611011050.33562.cservin@cromagnon.com> (raw)

I have tables representing a ledger system and the accounts on which it 
operates.

I want to do 2 things to all transactions altering the ledger tables.

First, all of the inserts into the ledger tables should be balanced ( They 
should sum to 0 ).  If not I want to abort the transaction.

Second, if the transaction is balanced I want to update the account balance on 
the account tables.


In other database systems that I have used when you have a statement level 
trigger you get access to the inserted/updated/deleted rows from that 
transaction as "virtual" tables within the trigger that you can manipulate.

I am currently using plpgsql to write my triggers.  I have not been able to 
figure out the "right" way to do this in PostgreSQL and would appreciate any 
advice.


Thanks,

Craig





Message-ID: <200611011050.33562.cservin@cromagnon.com>
Permalink:  ../200611011050.33562.cservin@cromagnon.com/
Also on:    postgresql.org/message-id/200611011050.33562.cservin@cromagnon.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: cservin@cromagnon.com
  Subject: Re: Statement Triggers and access to other rows in the transaction
  In-Reply-To: <200611011050.33562.cservin@cromagnon.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox