Using PL/pgSQL to Properly Define A Trigger

From: "Van Ingen, Lane" <lvaningen(at)ESNCC(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Using PL/pgSQL to Properly Define A Trigger
Date: 2005-02-10 19:50:13
Message-ID: A3FF4275060B76459B5C08A64AE330C86A3F@twmail.esncc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I am using PostgreSQL version 8.0. The manual (pages 589 - 590), which describes this process,
I think needs to clarified with an example.

Based on the trigger example (given on p. 590), I am assuming that the trigger variables (given on
p. 589) would be filled in by trigger as follows; can anyone confirm?

NEW: contains the row the trigger is asking the emp_stamp() to act on
OLD: not applicable to example 35-1 on p. 590
TG_NAME: emp_stamp
TG_WHEN: BEFORE
TG_LEVEL: ROW
TG_OP: INSERT or UPDATE -- this may be incorrect !
TG_RELID: -- not sure what this is; does trigger get OID from a system
table for name in TG_RELNAME ?
TG_RELNAME: emp
TG_NARGS: 0 -- not sure how to count 'arguments', am guessing it is '0',
because procedure was called as empstamp() [no args]
TG_ARGV[] : -- no arguments (TG_NARGS) appear to be passed in this example, so I
assume this value would be null. If two arguments were passed, how would they appear
to the function? Single quoted, and comma separated - e.g. 'xxxxxxx','xxxxxxxx' ?

Browse pgsql-novice by date

  From Date Subject
Next Message operationsengineer1 2005-02-10 20:21:33 Re: how to know this row has been referenced or not????
Previous Message Van Ingen, Lane 2005-02-10 18:53:42 PL/pgSQL: FOT Loops vs Cursors