Re: Problema con trigger de eliminación

From: "Erik Ferney Cubillos Garcia" <erikferneycubillos(at)gmail(dot)com>
To: "Emanuel CALVO FRANCO" <postgres(dot)arg(at)gmail(dot)com>
Cc: pgsql-es-ayuda <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Problema con trigger de eliminación
Date: 2008-11-10 16:13:46
Message-ID: 147151cc0811100813j27e19aecw40fa7392530c1b0d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

hola Emanuel, verás, no lo he probado, es el unico cambio que no he hecho,
voy a hacerlo y les comento como me fue

Gracias

2008/11/10 Emanuel CALVO FRANCO <postgres(dot)arg(at)gmail(dot)com>

> new no funciona solamente con BEFORE <ACCION>?
>
> 2008/11/10 Erik Ferney Cubillos Garcia <erikferneycubillos(at)gmail(dot)com>:
> > Buenos Días, Tardes, noches
> >
> > bueno verán tengo el siguiente Trigger con su respectiva función que se
> > ejecuta luego de hacer un DELETE, pero tengo un problema cada vez que
> > elimino un registro me sale el siguiente error
> >
> >
> > ERROR: record "new" is not assigned yet
> > DETAIL: The tuple structure of a not-yet-assigned record is
> indeterminate.
> > CONTEXT: PL/pgSQL function "ftBiEmpleU" line 43 at SQL statement
> >
> > ********** Error **********
> >
> > ERROR: record "new" is not assigned yet
> > SQL state: 55000
> > Detail: The tuple structure of a not-yet-assigned record is
> indeterminate.
> > Context: PL/pgSQL function "ftBiEmpleU" line 43 at SQL statement
> >
> >
> > aqui les dejo el trigger y la función
> >
> > CREATE TRIGGER "TgDBiEmple"
> > AFTER DELETE
> > ON bi_emple
> > FOR EACH ROW
> > EXECUTE PROCEDURE "ftBiEmpleD"();
> >
> > y la función
> >
> > CREATE OR REPLACE FUNCTION "ftBiEmpleD"()
> > RETURNS trigger AS
> > $BODY$
> > DECLARE
> > lDcCodTerc NUMERIC(13, 0);
> > lDccodempl NUMERIC(13, 0);
> > lSmCodEmpr INTEGER;
> > lSmCodDete INTEGER;
> > BEGIN
> > -- Se Verifica la existencia del Detalle Cliente en la entidad
> Detalle
> > Terceros (gn_deter)
> > LsmCodDete := NULL;
> >
> > select into lSmCodDete
> > cod_dete
> > from gn_deter
> > where cod_empr = old.cod_empr and
> > cod_terc = old.cod_empl and
> > UPPER(ini_modu) = UPPER('NM');
> >
> > -- Si no existe el tercero se inicializa su creación
> > IF lSmCodDete IS NOT NULL THEN
> > BEGIN
> > --print 'no es nulo el deter (Encontro)'
> > delete from gn_deter
> > where cod_empr = old.cod_empr and
> > cod_terc = old.cod_empl and
> > UPPER(ini_modu) = UPPER('NM');
> >
> > if exists(select * from pg_tables where tablename = ('cn_terce'))
> > then
> > begin
> > delete from cn_terce
> > where cod_empr = old.cod_empr and
> > cod_terc = old.cod_empl;
> > end;
> > end if;
> >
> > if exists(select * from pg_tables where tablename = ('ts_terce'))
> > then
> > begin
> > delete from ts_terce
> > where cod_empr = old.cod_empr and
> > cod_terc = old.cod_empl;
> > end;
> > end if;
> >
> > delete from gn_termo
> > where cod_empr = old.cod_empr and
> > cod_terc = old.cod_empl and
> > UPPER(ini_modu) = UPPER('NM');
> >
> > delete from gn_terce
> > where cod_empr = old.cod_empr and
> > cod_terc = old.cod_empl;
> >
> > end;
> > end if;
> >
> > RETURN OLD;
> >
> > END;
> >
> > $BODY$
> > LANGUAGE 'plpgsql' VOLATILE
> > COST 100;
> >
> > ALTER FUNCTION "ftBiEmpleD"() OWNER TO postgres;
> >
> > GRANT EXECUTE ON FUNCTION "ftBiEmpleD"() TO public;
> > GRANT EXECUTE ON FUNCTION "ftBiEmpleD"() TO postgres;
> >
> >
> > el return de la función lo he modificado por
> >
> > RETURN NULL;
> > RETURN NEW;
> > RETURN OLD;
> >
> > pero nada, sigue saliendo el mismo error,
> >
> > espero me puedan ayudar,
> >
> > Gracias
> >
> >
> > --
> > Atentamente,
> >
> >
> > ______________________________
> > ERIK FERNEY CUBILLOS GARCIA
> > Ing. Desarrollo - Kactus HR
> > DIGITAL WARE LTDA.
> > Calle 72 No. 12-65 Piso 2
> > Bogotá, Colombia
> > erikc(at)digitalware(dot)com(dot)co
> > www.digitalware.com.co
> >
>
>
>
> --
> Emanuel Calvo Franco
> Syscope Postgresql DBA
> BaPUG / AOSUG Member
>

--
Atentamente,

______________________________
ERIK FERNEY CUBILLOS GARCIA
Ing. Desarrollo - Kactus HR
DIGITAL WARE LTDA.
Calle 72 No. 12-65 Piso 2
Bogotá, Colombia
erikc(at)digitalware(dot)com(dot)co
www.digitalware.com.co

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Erik Ferney Cubillos Garcia 2008-11-10 16:19:43 Re: Problema con trigger de eliminación
Previous Message Erik Ferney Cubillos Garcia 2008-11-10 16:12:54 Re: Problema con trigger de eliminación