pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Martin Marques <martin@bugs.unl.edu.ar>
Cc: pgsql-sql@postgresql.org
Subject: Re: functions and triggers
Date: Tue, 20 Aug 2002 14:59:50 -0700 (PDT)
Message-ID: <20020820145456.F45900-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <1029879444.3d62b694112ac@bugs.unl.edu.ar>

On Tue, 20 Aug 2002, Martin Marques wrote:

> Quoting Stephan Szabo <sszabo@megazone23.bigpanda.com>:
>
> >
> > > The problemas are two:
> > >
> > > 1) when I try to create the trigger, it says that the function doesn't
> > exist.
> > > Why is this happening?
> >
> > You should probably show us what you were trying to do, but I'm going to
> > guess that the function doesn't have the right signature.  On
> > current versions, Trigger functions should return opaque and take no
> > arguments (any arguments given on the create trigger line are passed
> > in a different fashion).
>
> I have this function which works OK.
>
> CREATE FUNCTION ahora (integer) RETURNS integer AS '
> UPDATE usuarios SET tmodif = now()
> WHERE codigo = $1;
> SELECT 1 as RESULT;
> ' LANGUAGE SQL

Trigger functions have no args and return opaque and I don't think you
can use sql language functions, but I'm not sure.  Something like:

create function ahora_trigger() returns opaque as '
begin
 NEW.tmodif := now();
 return NEW;
end;'
language 'plpgsql';

should work as a before update trigger.




view thread (11+ messages)

Message-ID: <20020820145456.F45900-100000@megazone23.bigpanda.com>
Permalink:  ../20020820145456.F45900-100000@megazone23.bigpanda.com/
Also on:    postgresql.org/message-id/20020820145456.F45900-100000@megazone23.bigpanda.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: sszabo@megazone23.bigpanda.com, martin@bugs.unl.edu.ar
  Subject: Re: functions and triggers
  In-Reply-To: <20020820145456.F45900-100000@megazone23.bigpanda.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