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

Re: Trigger for Truncate event

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Trigger for Truncate event
Date: 2009-08-27 07:17:06
Message-ID: 20090827071705.GE9779@a-kretschmer.de (view raw or flat)
Thread:
Lists: pgsql-novice
In response to Jignesh Shah :
> Hi,
>  
> Could any one please point me to TRUNCATE trigger PostgreSQL example?
>  
> Thanks,

test=# create table jignesh (i int);
CREATE TABLE
test=*# create function trg_jignesh() returns trigger as $$begin raise notice 'in the function'; return new; end;$$ language plpgsql;
CREATE FUNCTION
test=*# create trigger trg1 before truncate on jignesh for each statement execute procedure trg_jignesh();
CREATE TRIGGER
test=*# create trigger trg2 after truncate on jignesh for each statement execute procedure trg_jignesh();
CREATE TRIGGER
test=*# truncate jignesh ;
NOTICE:  in the function
NOTICE:  in the function
TRUNCATE TABLE


ROLLBACK, Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

In response to

Responses

pgsql-novice by date

Next:From: A. KretschmerDate: 2009-08-27 07:21:57
Subject: Re: how can I finish my suscription?
Previous:From: Jignesh ShahDate: 2009-08-27 07:00:00
Subject: Trigger for Truncate event

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