Re: Problema con trigger de eliminación

From: "Alejandro D(dot) Burne" <alejandro(dot)dburne(at)gmail(dot)com>
To: "Erik Ferney Cubillos Garcia" <erikferneycubillos(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:09:49
Message-ID: 8398dc6d0811100809y4ced2e6alea0f593a473be330@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

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

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Emanuel CALVO FRANCO 2008-11-10 16:10:12 Re: Problema con trigger de eliminación
Previous Message Alejandro D. Burne 2008-11-10 16:06:20 Realizar cálculos sobre una tabla con una función