X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A0DFE8B9F87; Thu, 17 Feb 2005 09:35:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30112-07; Thu, 17 Feb 2005 09:35:28 +0000 (GMT) Received: from benhur.intern.intend.de (intern.intend-online.de [80.69.207.98]) by svr1.postgresql.org (Postfix) with ESMTP id 5AF098B9D1B; Thu, 17 Feb 2005 09:35:28 +0000 (GMT) Received: from thuja ([192.168.100.173]) by benhur.intern.intend.de (8.12.8p1/8.12.6/Benhur 8.12.6) with SMTP id j1H9TDM4016548; Thu, 17 Feb 2005 10:29:14 +0100 From: "Eugen Gass" To: Cc: Subject: Re: [SQL] Trigger Date: Thu, 17 Feb 2005 10:29:14 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal In-Reply-To: <4213B039.1070302@sajt.cz> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200502/182 X-Sequence-Number: 16350 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 > > >