new no funciona solamente con BEFORE <ACCION>?

2008/11/10 Erik Ferney Cubillos Garcia <[EMAIL PROTECTED]>:
> 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
> [EMAIL PROTECTED]
> www.digitalware.com.co
>



-- 
    Emanuel Calvo Franco
   Syscope Postgresql DBA
     BaPUG / AOSUG Member
--
TIP 4: No hagas 'kill -9' a postmaster

Responder a