Re: [HACKERS] SQL Triggers

From: jwieck(at)debis(dot)com (Jan Wieck)
To: darcy(at)druid(dot)net (D'Arcy J(dot)M(dot) Cain)
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] SQL Triggers
Date: 1998-09-24 08:55:50
Message-ID: m0zM7Bn-000EBPC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> Is this an error on my part or is there a bug in the CREATE TRIGGER
> code?
>
> darcy=> CREATE FUNCTION function_dead(int)
> darcy-> RETURNS int
> darcy-> AS 'UPDATE bid SET live = \'f\' WHERE item_id = $1;
> darcy'> SELECT 1 AS ignore_this'
> darcy-> LANGUAGE 'sql';
> CREATE
> darcy=> CREATE TRIGGER trigger_dead BEFORE INSERT OR UPDATE
> darcy-> ON bid
> darcy-> FOR EACH ROW
> darcy-> EXECUTE PROCEDURE function_dead (item_id);
> ERROR: CreateTrigger: function function_dead () does not exist
> darcy=> SELECT function_dead(1);
> function_dead
> -------------
> 1
> (1 row)
>
> darcy=> DROP FUNCTION function_dead(int);
> DROP
> darcy=>
>
> Note that the CREATE FUNCTION works as it can be used as in the SELECT
> and it can be dropped proving (?) that it existed. I think I have
> all the argument types right. I tried it with int4 as well.
>
> --
> D'Arcy J.M. Cain <darcy(at){druid|vex}.net> | Democracy is three wolves
> http://www.druid.net/darcy/ | and a sheep voting on
> +1 416 424 2871 (DoD#0082) (eNTP) | what's for dinner.
>
>

The arguments aren't right and the return type too. Trigger
procedures take no arguments in their definition and return
OPAQUE type. They really return a tuple of the table they are
actually fired for.

Take a look at PL/pgSQL and it's docs which is already in the
CVS and will be shipped with 6.4.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck(at)debis(dot)com (Jan Wieck) #

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 1998-09-24 09:20:08 fix for multi-byte partial truncating
Previous Message Jose' Soares 1998-09-24 07:39:46 bug on CHAR_LENGTH function ?