Basic Trigger

From: "Roberto de Amorim" <roberto(at)smartbit(dot)inf(dot)br>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Basic Trigger
Date: 2002-11-18 11:13:25
Message-ID: 006b01c28ef3$84fb3d10$04c8a8c0@Desenvolvimento
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

I did some Trigger to set default values for each row interted.
so, I'm using NEW.ID = NEXTVAL(''products_id_seq'');
but the column do not assum this value...
must I execute any other command before to set a value for NEW?

CREATE OR REPLACE FUNCTION "f_products"() RETURNS "opaque" AS '
BEGIN
NEW.ID = NEXTVAL(''products_id_seq'');
RETURN NEW;
END' LANGUAGE 'plpgsql'

CREATE TRIGGER "t_classes" AFTER INSERT ON "products" FOR EACH ROW EXECUTE
PROCEDURE f_products();

Roberto de Amorim +55 48 346-2243
Software engineer at SmartBit Software
roberto(at)smartbit(dot)inf(dot)br

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Einar Karttunen 2002-11-18 11:30:15 Re: Basic Trigger
Previous Message Richard Huxton 2002-11-18 10:56:23 Re: data restore