Re: Functions and triggers can anyone help - Mailing list pgsql-general

From Joe Conway
Subject Re: Functions and triggers can anyone help
Date
Msg-id 3E4134A9.5080704@joeconway.com
Whole thread Raw
In response to Functions and triggers can anyone help  (RobertD.Stewart@mail.state.ky.us)
List pgsql-general
RobertD.Stewart@mail.state.ky.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


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Functions and triggers can anyone help
Next
From: Stephan Szabo
Date:
Subject: Re: not exactly a bug report, but surprising behaviour