Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> How to create a log file?

How to create a log file?

From: Fernando Carvalho <f.carvalho_at_mail.telepac.pt>
Date: Tue, 11 Aug 1998 11:50:12 +0200
Message-ID: <6qp7og$qdc$1@duke.telepac.pt>


I want to create a log file to register changes by field in a LogTable with the following simplified structure:

CREATE TABLE LogTable
(

  TableName        VARCHAR2(30) NOT NULL,
  KeyValue            VARCHAR2(30) NOT NULL,
  FieldName          VARCHAR2(30) NOT NULL,
  OldFieldValue VARCHAR2(80),
  NewFieldValue VARCHAR2(80),
  User                    VARCHAR2(30) NOT NULL,
)+ADs-

To catch all the changes in Table1 work table, I must create a trigger after update on Table1 for each row.

But how can I write in PL/SQL the following pseudo code for the trigger?

begin
  for i in +AFs-1..FieldCount+AF0- loop     if :new.Field+AFs-i+AF0-.Value +ADwAPg- :old.Field+AFs-i+AF0-.Value then

      insert into LogTable
      values ('Table1', :new.KeyField.Value, Field+AFs-i+AF0-.Name,
:old.Field+AFs-i+AF0-.Value, :new.Field+AFs-i+AF0-.Value, User)+ADs-

    end if+ADs-
  end loop+ADs-
end+ADs-

Tanks in advance

Fernando Carvalho Received on Tue Aug 11 1998 - 04:50:12 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US