problemas con trigger

From: Juan <smalltalker(dot)marcelo(at)gmail(dot)com>
To: Ayuda <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: problemas con trigger
Date: 2012-11-06 16:38:44
Message-ID: CAKizN9whcehz6g1eEbgtU09npzK6WQnCoPyA0tC5RjGvEperCg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Gente

Tengo un trigger declarado en una tabla, declarada de la sig. manera

-- Table: dato_d

-- DROP TABLE dato_d;

CREATE TABLE dato_d
(
id bigserial NOT NULL,
fecha_alta timestamp without time zone NOT NULL,
fecha_baja timestamp without time zone,
fecha_ult_mod timestamp without time zone NOT NULL,
usuario_alta character varying(50) NOT NULL,
usuario_baja character varying(50),
usuario_ult_mod character varying(50) NOT NULL,
codigo character varying(30),
inactivo integer,
nombre character varying(255),
id_dominio bigint,
CONSTRAINT d_pkey PRIMARY KEY (id),
CONSTRAINT sdgdgdfgdfgdfgdFOREIGN KEY (id_dominio)
REFERENCES d (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
ALTER TABLE dato_d
OWNER TO tsuser;

-- Trigger: tr_datos_d on dato_d

-- DROP TRIGGER tr_datos_dom ON dato_d;

CREATE TRIGGER tr_datos_d
BEFORE INSERT OR UPDATE OR DELETE
ON dato_d
FOR EACH ROW
EXECUTE PROCEDURE tr_datos_d();

PERO: en mi trigger tengo un if por delete or update or insert

segun entendi el trigger llama con un "parametro" NEW u OLD representando
la row que se altera,
Para testear esta funcionalidad le hice un update
update dato_d set fecha_baja = fecha_baja ;
No modifico nada, pero lo que motiva este corre es que algunas veces parece
que el OLD y el NEW vienen en null
de manera que si intento acceder a el campo id me sale el error 'valor no
inicializado'

cualquier ayuda sera agradecido.
saludos

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Raul Andres Gutierrez Alejo 2012-11-06 16:47:29 Re: problemas con trigger
Previous Message Pedro Ricardo 2012-11-06 15:54:23 HASH en INNER JOINS