From: | "Ing(dot) Esneiker Enriquez Cabrera" <eenriquez(at)cav(dot)desoft(dot)cu> |
---|---|
To: | "'POSTGRES'" <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | RE: duda sobre trigger |
Date: | 2014-04-03 18:40:35 |
Message-ID: | 003001cf4f6c$339dde00$9ad99a00$@desoft.cu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
El código de la función es:
CREATE OR REPLACE FUNCTION actualizar_carpeta_mensaje()
RETURNS trigger AS
$BODY$
BEGIN
IF (TG_OP = 'DELETE') THEN
update carpeta_mensaje set nodo_terminal = true where id = OLD.id_padre
and id not in (select id_padre from carpeta_mensaje where eliminado is false
and id_padre is not null);
END IF;
IF (TG_OP = 'UPDATE') THEN
if (NEW.eliminado IS TRUE) then
update carpeta_mensaje set nodo_terminal = true where id in (select
id_padre from carpeta_mensaje where eliminado is true and id_padre is not
null);
end if;
if (NEW.eliminado IS FALSE) then
update carpeta_mensaje set nodo_terminal = false where id in (select
id_padre from carpeta_mensaje where eliminado is false and id_padre is not
null);
end if;
END IF;
IF (TG_OP = 'INSERT') THEN
if(NEW.id_padre is not null) then
update carpeta_mensaje set nodo_terminal = false where id =
NEW.id_padre;
update carpeta_mensaje set id_menu_padre = m.id_menu_padre from
carpeta_mensaje m where m.id = NEW.id_padre and carpeta_mensaje.id = NEW.id;
end if;
END IF;
RETURN NEW;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION actualizar_carpeta_mensaje()
OWNER TO postgres;
Al ejecutar update carpeta_mensaje set eliminado = false el servidor me
retorna:
ERROR: límite de profundidad de stack alcanzado
HINT: Incremente el parámetro de configuración «max_stack_depth»
(actualmente 2048kB), después de asegurarse que el límite de profundidad de
stack de la plataforma es adecuado.
CONTEXT: sentencia SQL: «SELECT 1 FROM ONLY "public"."nmusuario" x WHERE
"id" OPERATOR(pg_catalog.=) $1 FOR SHARE OF x»
sentencia SQL: «update carpeta_mensaje set nodo_terminal = false where id in
(select id_padre from carpeta_mensaje where eliminado is false and id_padre
is not null)»
PL/pgSQL function "actualizar_carpeta_mensaje" line 14 at sentencia SQL
sentencia SQL: «update carpeta_mensaje set nodo_terminal = false where id in
(select id_padre from carpeta_mensaje where eliminado is false and id_padre
is not null)»
y esto una cantidad de veces exagerada.
Espero que me puedan ayudar con este tema que aparentemente debería ser una
cuestión muy simple.
Saludos,
Ing. Esneiker Enriquez Cabrera
Esp. B en Ciencias Informáticas
Desoft en Ciego de Ávila. Joaquín de Aguero esq. Calle 2. Ciego de Ávila.
Cuba.
Telf.: 53 33 22 8971, email.: eenriquez(at)cav(dot)desoft(dot)cu
De: Ing. Esneiker Enriquez Cabrera [mailto:eenriquez(at)cav(dot)desoft(dot)cu]
Enviado el: jueves, 03 de abril de 2014 13:54
Para: 'POSTGRES'
Asunto: duda sobre trigger
Hola a todos.
Cómo puedo en un trigger preguntar si se modificó una columna específica de
una tabla? Por ejemplo si se modificó la columna stock. En la documentación
de los trigger no lo encuentro.
Muchas gracias
Saludos,
Ing. Esneiker Enriquez Cabrera
Esp. B en Ciencias Informáticas
Desoft en Ciego de Ávila. Joaquín de Aguero esq. Calle 2. Ciego de Ávila.
Cuba.
Telf.: 53 33 22 8971, email.: eenriquez(at)cav(dot)desoft(dot)cu
__________ Información de ESET NOD32 Antivirus, versión de la base de firmas
de virus 9621 (20140401) __________
ESET NOD32 Antivirus ha comprobado este mensaje.
From | Date | Subject | |
---|---|---|---|
Next Message | Fernando Hevia | 2014-04-03 18:44:50 | Re: duda sobre trigger |
Previous Message | Aldo Amarilla | 2014-04-03 18:07:14 | Re: duda sobre trigger |