Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] SQL Triggers

From: darcy(at)druid(dot)net (D'Arcy J(dot)M(dot) Cain)
To: jwieck(at)debis(dot)com
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] SQL Triggers
Date: 1998-09-25 17:01:26
Message-ID: m0zMbFG-00006FC@druid.net (view raw or flat)
Thread:
Lists: pgsql-hackers
Thus spake Jan Wieck
> > 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)
> 
>     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.

Not sure I follow.  The argument is an int (or int4 as it defaults to)
and I tried various combos of int and int4 in the procedure definition

As for the opaque type return, I get an error message when I try to
create an SQL function returning opaque.  The "SELECT 1 AS ignore_this"
is taken straight from the examples.

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

I have the current sources (I sup daily) but I couldn't find any examples
of fcreate trigger.

-- 
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.

In response to

Responses

pgsql-hackers by date

Next:From: D'Arcy J.M. CainDate: 1998-09-25 17:07:59
Subject: Re: unfortunately...
Previous:From: Bruce MomjianDate: 1998-09-25 15:53:52
Subject: Re: [DOCS] Installation instructions

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group