Обсуждение: Trigger

Поиск
Список
Период
Сортировка

Trigger

От
"Eugen Gass"
Дата:
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


Re: Trigger

От
Michael Fuhr
Дата:
On Wed, Feb 16, 2005 at 02:44:30PM +0100, Eugen Gass wrote:
> 
> I'm trying to create a trigger on PostgreSQL

See the "Server Programming" part of the documentation (substitute
the appropriate version of PostgreSQL in the links):

http://www.postgresql.org/docs/8.0/static/server-programming.html
http://www.postgresql.org/docs/8.0/static/triggers.html
http://www.postgresql.org/docs/8.0/static/plpgsql.html
http://www.postgresql.org/docs/8.0/static/plpgsql-trigger.html

If you still have trouble then please post the PostgreSQL code you
tried, describe what you'd like to happen, and explain what actually
does happen.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/


Re: Trigger

От
"Eugen Gass"
Дата:

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@sajt.cz]
Gesendet: Mittwoch, 16. Februar 2005 21:43
An: Eugen Gass
Cc: pgsql-sql@postgresql.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
>
>
>


Re: Trigger

От
Pavel Rabel
Дата:
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
>
>  
>