AYUDA CON TRIGER - URGENTE

From: fulanito detal <fulanito000(at)hotmail(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: AYUDA CON TRIGER - URGENTE
Date: 2008-06-20 14:36:25
Message-ID: BLU121-W6D320CDC7F79355313EE3FDA50@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

HOLA, les pido ayuda con un triger que no me sale..
Estoy intentando hacer un triger que cuando inserto registros a una tabla, que si hay un registro con ciertos campos iguales no inserta el nuevo registro, pero modifica un campo del viejo llamado orige , concatenandole el origen del nuevo campo...
el triger compilo pero a la hora de hacer un copy , me sale el siguiente error:

ERROR: UPDATE no está permitido en una función no-«volatile»
CONTEXTO: sentencia SQL: «update imagenfisica set imgfis_origen = $1 where id = $2 »
PL/pgSQL function "eliminarepetidos" line 14 at SQL statement
COPY imagenfisica, línea 1: «2450048|N|1738|1933|N19331738000115.TIF|14/05/2008 10:15:20|120432|SERVIDOR_4»

alguien tiene idea que quiere decir, y como lo puedo arregla??

aca abajo les dejo el trigger

muchas gracias

jorge

declare
im imagenfisica%ROWTYPE;
begin
SELECT INTO im * FROM imagenfisica i
WHERE i.imgfis_nomarch = new.imgfis_nomarch
and i.imgfis_nrolibro = new.imgfis_nrolibro
and i.imgfis_tpolibro = new.imgfis_tpolibro
and i.imgfis_anio = new.imgfis_anio;
IF NOT FOUND THEN
--RAISE EXCEPTION ''''View '''' || key || '''' not found'''';
-- RETURN null;
END IF;
IF im.imgfis_nomarch is not null THEN
update imagenfisica
set imgfis_origen = imgfis_origen || '-'|| new.imgfis_origen
where id = im.id;

RETURN NULL;
END IF;

RETURN NEW;
end;

_________________________________________________________________
MSN Noticias
http://noticias.msn.es/comunidad.aspx

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Juan Carlos Badillo Goy 2008-06-20 19:29:17 Ayuda con una sentencia SQL
Previous Message Alvaro Herrera 2008-06-20 13:18:59 Re: Archivos Cad