Re: trigger-procedure without plpgsql - Mailing list pgsql-general

From Holger Krug
Subject Re: trigger-procedure without plpgsql
Date
Msg-id 20020201150040.A1504@dev12.rationalizer.com
Whole thread Raw
In response to trigger-procedure without plpgsql  (Picrate <picrate@ibelgique.com>)
List pgsql-general
On Fri, Feb 01, 2002 at 02:24:41PM +0100, Picrate wrote:
> Hi all,

> I!m having a hard time getting out well with trigger-procedures
> without using plpgsql. I cannot put a hand on some documentation about
> writing procedures in LANGUAGE 'sql'. There must be some info
> somewhere, isn't it?

Everybody would have a hard time in this case. It's simply impossible
with plain SQL. Use PLPGSQL.

The docs you need are the chapters 20. and 23. of PostgreSQL
documentation.

> I am trying to make a procedure which can update a table as reaction
> to an insert into another table. For that, I need to get the id of the
> table to update but I can't get it in any way because I don't know how
> to call it. The "new.id_table_to_update" doesn't seem to be recognized
> (the "new" term into the 'sql' procedure doesn't seem to be the right
> syntax to reference it).

NEW works only in PLPGSQL not in SQL.

> I would like to use 'sql' language for that 'cause I don't see any
> interest in doing it with plpgsql if I can do it without it.

You cannot.

> If someone could help... or at least mention some place where to
> learn how to do this, I would be very glad.

Read the docs cited above or look under techdocs.postgresql.org, there
should be plenty examples.

--
Holger Krug
hkrug@rationalizer.com

pgsql-general by date:

Previous
From: Mike Mascari
Date:
Subject: Re: ORDER BY in \dt+ ?
Next
From: Tom Lane
Date:
Subject: Re: timestamp weirdness