Problema con trigger de eliminación

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

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

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Alejandro D. Burne 2008-11-10 16:06:20 Realizar cálculos sobre una tabla con una función
Previous Message Edwin Quijada 2008-11-10 15:45:39 RE: SELECT muy LENTO