Ver Mensaje Individual
  #1  
Antiguo 14-12-2006
Avatar de juanmdq
juanmdq juanmdq is offline
Miembro
 
Registrado: dic 2004
Posts: 52
Reputación: 20
juanmdq Va por buen camino
Trigger y campo CLOB

Hola a todos:
Dejo esta pregunta en el foro porque luego de buscar un rato largo por internet no encontre nada que haga referencia al problema que tengo.
El problema es que para realizar la auditoria de unas tablas tenemos definidos unos triggers(el trigger hace simplemente un insert en otra tabla con la misma estructura de la tabla a auditar). hasta ahora no teniamos problemas,HASTA QUE creamos una tabla con un campo de tipo CLOB.
El tema esta en que en la tabla de auditoria el valor del campo CLOB nunca se setea, sin embargo el valor en la tabla origen existe.

Código SQL [-]
CREATE OR REPLACE TRIGGER AUDITATABLAX
AFTER DELETE OR INSERT OR UPDATE
ON TABLAX
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
    estado VARCHAR(10);

BEGIN
    IF DELETING THEN
        estado := 'BAJA';
        INSERT INTO AUDITREQUERIMIENTOS (
                    FECHA,
                    estado,
                    OTROSDATOS,
                    OBSERVACIONES)
          VALUES(   
                    SYSDATE,
                    estado,
                    :OLD.OTROSDATOS,
                    :OLD.OBSERVACIONES
          );

    ELSIF INSERTING OR UPDATING THEN
        IF INSERTING THEN  estado := 'ALTA';
        ELSIF UPDATING THEN estado := 'MODI';
        END IF;

        INSERT INTO AUDITREQUERIMIENTOS (
                    FECHA,
                    estado,
                    OTROSDATOS,
                    OBSERVACIONES)
          VALUES(   
                    SYSDATE,
                    estado,
                    :NEW.OTROSDATOS,
                    :NEW.OBSERVACIONES
          );

    END IF;

END;

por ejemplo si inserto un registro con los valores
otrosdatos = 'PRUEBA' y
observaciones = 'OBSERVACIONES DE PRUEBA'

en la tabla de auditoria obtengo
SYSDATE estado OTROSDATOS OBSERVACIONES
14/12/2006 'ALTA' 'PRUEBA'

si modifico el registro anterior pasa exactamento lo mismo.
modifico 'PRUEBA' por 'OTRA PRUEBA'

en la tabla de auditoria obtengo
SYSDATE estado OTROSDATOS OBSERVACIONES
14/12/2006 'ALTA' 'PRUEBA'
14/12/2006 'MODI' 'OTRA PRUEBA'


Por curiosidad probe de cambiar el trigger para que en vez de insertar en la tabla de auditoria el nuevo valor (:NEW.OBSERVACIONES) inserte el viejo (:OLD.OBSERVACIONES), y el valor viejo lo obtiene y lo inserta correctamente.


Si alguien tiene una idea de lo que puede estar pasando, o se le ocurre alguna prueba que pueda realizar le agradeceria mucho que lo comente.

desde ya muchas gracias.



P.D.:Version de oracle
Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Prod
PL/SQL Release 10.1.0.3.0 - Production
CORE 10.1.0.3.0 Production
TNS for Linux: Version 10.1.0.3.0 - Production
__________________
Al infierno se llega por atajos.
Responder Con Cita