Re: habilitar/deshabilitar triggers

From: "Jaime Casanova" <systemguards(at)gmail(dot)com>
To: deepthroat <dblackbeer(at)gmail(dot)com>, "lista postrges" <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: habilitar/deshabilitar triggers
Date: 2006-09-21 03:42:13
Message-ID: c2d9e70e0609202042v533a8d05p834e103fe68b41c1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

On 9/20/06, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
> deepthroat escribió:
> > Quisiera saber si en postgresql existe algo equivalente a la siguiente
> > sentencia en oracle:
> >
> > para habilitar:
> > ALTER TRIGGER nombre_del_trigger ENABLE;
> >
> > para deshabilitar:
> > ALTER TRIGGER nombre_del_trigger DISABLE;
>
> ALTER TABLE tab ENABLE/DISABLE TRIGGER trig
>

cabe aclarar que esta forma de ALTER TABLE esta disponible desde el 8.1
http://www.postgresql.org/docs/8.1/static/sql-altertable.html

antes de eso (es decir, <= 8.0) debes hacer un update en los catalogos
de postgres (mmm):

UPDATE pg_catalog.pg_class
SET reltriggers = 0
WHERE oid = 'nombre_tabla'::pg_catalog.regclass;

y luego para rehabilitarlos:

UPDATE pg_catalog.pg_class
SET reltriggers = (SELECT pg_catalog.count(*) FROM pg_catalog.pg_trigger
WHERE pg_class.oid=tgrelid)
WHERE oid = 'nombre_tabla'::pg_catalog.regclass;

--
Atentamente,
Jaime Casanova

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
Richard Cook

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Jaime Casanova 2006-09-21 04:11:41 Re: Vistas no editables
Previous Message Alvaro Herrera 2006-09-20 20:06:37 Re: habilitar/deshabilitar triggers