Re: Functions and triggers can anyone help

From: Joe Conway <mail(at)joeconway(dot)com>
To: RobertD(dot)Stewart(at)mail(dot)state(dot)ky(dot)us
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Functions and triggers can anyone help
Date: 2003-02-05 15:58:33
Message-ID: 3E4134A9.5080704@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

RobertD(dot)Stewart(at)mail(dot)state(dot)ky(dot)us wrote:
> I'm having a problem with setting up a function and a trigger for one of me
> tables. I have just started using Postgresql and I'm trying to convert my
> Oracle database over to see how it runs.
>
[...snip...]
>
> And Here is my Postgresql function but when I try to set the trigger it says
> it can't find the function (it does not exist)
>
> CREATE FUNCTION set_username4(varchar, varchar) RETURNS opaque AS '
>

You haven't provided a complete example, so it's hard to help. One thing I did
notice is that your function is ill-defined if you intend to use it for a
trigger. See:
http://www.us.postgresql.org/users-lounge/docs/7.3/postgres/plpgsql-trigger.html

Quote with emphasis added:
"PL/pgSQL can be used to define trigger procedures. A trigger procedure is
created with the CREATE FUNCTION command as a function with no arguments and a
return type of TRIGGER. Note that the function must be declared with no
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
arguments even if it expects to receive arguments specified in CREATE TRIGGER
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
--- trigger arguments are passed via TG_ARGV, as described below."

HTH,

Joe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2003-02-05 16:06:41 Re: not exactly a bug report, but surprising behaviour
Previous Message Tom Lane 2003-02-05 15:26:02 Re: Functions and triggers can anyone help