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

Re: [SQL] Trigger

From: "Eugen Gass" <gass(at)intend(dot)de>
To: <pgsql-sql(at)postgresql(dot)org>
Cc: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: [SQL] Trigger
Date: 2005-02-17 09:29:14
Message-ID: LKEAIFJAEICHBHJOIFOCCECDCAAA.gass@intend.de (view raw or flat)
Thread:
Lists: pgsql-adminpgsql-sql

Hi,
Thank you ALL for the fast help

it works fine with following code:

CREATE OR REPLACE FUNCTION synchronize () RETURNS trigger AS 'BEGIN
NEW.objectid := NEW.gid; RETURN NEW; END;' LANGUAGE plpgsql;

CREATE TRIGGER syncl_holz_lager AFTER INSERT ON holz_lagerplatz FOR EACH ROW
EXECUTE PROCEDURE synchronize();

Best Regards

Eugen




-----Urspr√ľngliche Nachricht-----
Von: Pavel Rabel [mailto:pavel(at)sajt(dot)cz]
Gesendet: Mittwoch, 16. Februar 2005 21:43
An: Eugen Gass
Cc: pgsql-sql(at)postgresql(dot)org
Betreff: Re: [SQL] Trigger


It requires a bit more work in PostgreSQL to create a trigger.

 From the documentation: "It is not currently possible to write a
SQL-language trigger function. Trigger functions can be written in C or
in some of the available procedural languages."

I guess you will prefer to write the trigger in PL/pgSQL, have a look at
http://www.postgresql.org/docs/8.0/interactive/plpgsql-trigger.html

Regards

Pavel

Eugen Gass wrote:

>Hi,
>
>I'm trying to create a trigger on PostgreSQL
>
>it should be like an oracle(sql) sample code:
>
>create or replace trigger frei_polygon_sync
>after INSERT on frei_polygon
>Referencing NEW as newROW
>for each row
>Begin
> :newRow.objektid :=  :newRow.gid;
> :
>end;
>
>Can sombody help me to do the same on Postrgres
>
>Thanks
>
>Best Regards
>
>EG
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
>               http://www.postgresql.org/docs/faq
>
>
>


pgsql-admin by date

Next:From: thomas.revellDate: 2005-02-17 10:24:30
Subject: Determining current WAL
Previous:From: Dick DaviesDate: 2005-02-16 23:15:52
Subject: Re: empty a database

pgsql-sql by date

Next:From: AL ELKDate: 2005-02-17 10:18:48
Subject: diff value retuns, debug mode and play mode
Previous:From: dawnskyDate: 2005-02-17 00:45:06
Subject:

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