Re: [GENERAL] Creating Triggers

From: Ed Loehr <eloehr(at)austin(dot)rr(dot)com>
To: Sarah Officer <officers(at)aries(dot)tucson(dot)saic(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] Creating Triggers
Date: 2000-01-19 22:45:02
Message-ID: 38863E6E.1D0BFADB@austin.rr.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sarah Officer wrote:
>
> - A value must be returned if a return type is specified. The old &
> new records are available as return values from the plpgsql
> function.

Unfortunately, OLD and NEW are only available in the function that's
directly called by the trigger, not subsequent functions in the call
chain, IIRC.

> - The body of a plpgsql function looks like sql except for reference
> to old and new. The SQL part of the function must be enclosed with
> 'begin' and 'end;' or there will be a compiler error at run time.

What goes between 'begin' and 'end' are PL/pgSQL statements, of which
SQL is almost a subset. PL/pgSQL also has a number of plain vanilla
programming language constructs (if-then, loops, etc.).

> - If a trigger function is dropped and recreated, the corresponding
> trigger must also be dropped and recreated. Otherwise postgres
> 6.5.3 will give a runtime error that the cache lookup failed.

More generally, any function that gets dropped/recreated requires all
the functions/triggers above it in the call chain to be recreated,
IIRC.

Cheers,
Ed Loehr

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ing. Roberto Andrade Fonseca 2000-01-19 23:08:44 Benchmarks for pgsql?
Previous Message Sean Carmody 2000-01-19 22:34:45 RE: [GENERAL] Problems with operator '%' within a select