Trigger

From: Leonardo Porras Sànchez <lporras(at)siid-ltda(dot)com>
To: postgres <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Trigger
Date: 2006-03-14 18:58:55
Message-ID: 4417126F.5040403@siid-ltda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Tengo el siguiente trigger para actualizar la informacion de un campo de
la tabla al cual quiero insertar o modificar registros; cuando hago la
modificacion de un registro la funcion se como el servidor y no me
actualiza el campo... ¿Ques estare asiendo mal..?

Agradesco la atención prestada.

DROP TRIGGER tgr_ssp_assidate ON surface_locsamples;
DROP FUNCTION ssp_assidate();

CREATE OR REPLACE FUNCTION ssp_assidate()
RETURNS "trigger" AS
$BODY$
DECLARE
gpt surface_gps_point%ROWTYPE;
psr surface_polygonal%ROWTYPE;
sample varchar(8);
sdate date;
polygonal varchar(15);
ssource varchar(16);
BEGIN
sample = OLD.ssp_id_sample;
ssource = OLD.ssp_source;
IF ssource='GPS' THEN
SELECT * INTO gpt FROM surface_gps_point WHERE gpt_id_sample=sample;
IF FOUND THEN
sdate = gpt.gpt_date_hour;
UPDATE surface_locsamples SET ssp_date=sdate WHERE
ssp_id_sample=sample;
END IF;
ELSEIF (ssource='TAPE AND COMPASS') THEN
polygonal = OLD.ssp_psr_id
SELECT * INTO psr FROM surface_polygonal WHERE psr_id=polygonal;
IF FOUND THEN
sdate = psr.psr_date_begun;
UPDATE surface_locsamples SET ssp_date=sdate WHERE
ssp_id_sample=sample;
END IF;
END IF;
RETURN NEW;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION ssp_assidate() OWNER TO greystar;

CREATE TRIGGER tgr_ssp_assidate
BEFORE UPDATE
ON surface_locsamples
FOR EACH ROW
EXECUTE PROCEDURE ssp_assidate();

Attachment Content-Type Size
lporras.vcf text/x-vcard 417 bytes

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Kelly González Enríquez 2006-03-14 19:24:29 importacion solucianada
Previous Message Mario Gonzalez 2006-03-14 15:52:00 Re: importando