Re: How to build a TRIGGER in POSTGERSQL

From: alla(at)sergey(dot)com (Alla)
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to build a TRIGGER in POSTGERSQL
Date: 2001-06-18 20:53:16
Message-ID: 9275d56e.0106181253.27beed20@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> CREATE SEQUENCE AD_MNG_SYS_SEQ MINVALUE 1 MAXVALUE 999999 CYCLE;
Stays pretty much the same

>
> CREATE TRIGGER AD_MNG_SYS_TRIG
> BEFORE INSERT ON AD_MNG_SYS
> REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW
> BEGIN
> Select AD_MNG_SYS_SEQ.NEXTVAL INTO :new.AMS_ID FROM Dual;
> END;
> /

create function ad_mng_sys_proc()
returns opaque as '
begin
new.ams_id := nextval(''ad_mng_sys_seq'');

return new;
end;
' LANGUAGE 'plpgsql';

create trigger ad_mng_sys_trig
before insert on ad_mng_sys
for each row
execute procedure ad_mng_sys_proc();

> 2) what is equal to 'sysdate' (to get/put the system date in a
> table) in PostGerSQL.
now()

Enjoy :-))

Alla Gribov

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Christopher Smith 2001-06-18 21:10:27 Problems ensuring uniqueness?
Previous Message Peter Eisentraut 2001-06-18 20:49:33 Re: Subselects, the Oracle way