Re: Problema con trigger de eliminación

From: "Erik Ferney Cubillos Garcia" <erikferneycubillos(at)gmail(dot)com>
To: "Alejandro D(dot) Burne" <alejandro(dot)dburne(at)gmail(dot)com>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Problema con trigger de eliminación
Date: 2008-11-10 16:12:54
Message-ID: 147151cc0811100812w35c32b64p40fe138850d7a8d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Hola... gracias por tu respuesta, pero la verdad es que no estoy usando el
new, es por eso que se me hace muy raro, bueno la verdad es que ya lo he
revisado, pero no sé si se me está escapando algo, saludos y gracias

2008/11/10 Alejandro D. Burne <alejandro(dot)dburne(at)gmail(dot)com>

> 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
> >
>
> un trigger de delete no puede tener NEW, sólo OLD
>
> Saludos, Alejandro
>

--
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:13:46 Re: Problema con trigger de eliminación
Previous Message Emanuel CALVO FRANCO 2008-11-10 16:10:12 Re: Problema con trigger de eliminación