Re: User-Defined functions

From: Jeff Davis <list-pgsql-general(at)empires(dot)org>
To: Jenia <jenia(dot)k(at)ntlworld(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: User-Defined functions
Date: 2002-09-03 08:58:29
Message-ID: 200209030158.29100.list-pgsql-general@empires.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Triggers have to return type "opaque" for procedural language functions (like
if they're written in pl/pgsql). If you need the function defined in C, it
looks like this link might help you out:
http://www.postgresql.org/idocs/index.php?triggers.html

Note that it's pretty easy to make a trigger in pl/pgsql, and from first
glance it looks somewhat more difficult to write it in C. It, of course,
depends on how important performance is to your particular application.

Regards,
Jeff Davis

On Tuesday 03 September 2002 01:22 am, Jenia wrote:
> Hi
>
> I am having troubles creating triggers using my functions ..
> I have created the shared library with some functions which
> appear to work in SELECT statement ..
> But when I try to use those function in CREATE TRIGGER statement
> it says that function doesn't exist ...
>
> Any ideas ?
> Thanks a lot
>
> Yevgeny
>
> I am using PostgresQL 7.2 on RedHat 7.3 ..
>
>
> # load '/usr/local/lib/libtest.so';
> LOAD
> # create function more_than(integer,integer) returns integer
> # as '/usr/local/lib/libtest.so','test' language c;
> CREATE
> # select more_than(4,6) as answer;
> answer
> --------
> 0
> (1 row)
>
> # select more_than(14,6) as answer;
> answer
> --------
> 1
> (1 row)
>
> # create trigger t_one
> # after insert on t_table1 for each row
> # execute procedure more_than(7, 4);
> ERROR: CreateTrigger: function more_than() does not exist
> #
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lee Kindness 2002-09-03 09:03:21 Porting SQL Server -> PostgreSQL ( SELECT INTO problem... )
Previous Message Patrick FICHE 2002-09-03 08:53:16 Porting SQL Server -> PostgreSQL ( SELECT INTO problem... )