Question Audit Database changes

Tarun213706

New Member
Hi,

I have to audit Database changes in Progress 4GL.
I dont have to use Database trigger . I want to implement it using Data Access Layer(OOPS concept).
I appreciate if anyone can help me.
 

Tarun213706

New Member
I have to Create a class that generates data appropriately in to the new audit logging table
· This class should be accessed from existing code (where table modifications are excitingly occurring)
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
Hi,

I have to audit Database changes in Progress 4GL.
I dont have to use Database trigger . I want to implement it using Data Access Layer(OOPS concept).
I appreciate if anyone can help me.

Depending on the scope of your auditing needs you may want to look at the information in the Progress documentation on OpenEdge Auditing. It is available from version 10.1A onward. Look in the DB Admin and Core Business Services manuals.

You can provide a more robust audit trail that way than by rolling your own audits in ordinary 4GL tables. You will however have to write your own reporting code, and you will have some additional DB maintenance overhead: altering structure to add auditing areas, configuring security, enabling auditing, archiving audit data to an archive DB, etc.
 

TomBascom

Curmudgeon
I don't see anything that resembles a business case for rolling your own class instead of implementing OE auditing. Are you just unaware of the OE Auditing product?
 

Tarun213706

New Member
I am new to Progress. I found how to audit DB changes with the help of DB triggers .
Can anyone help me out with the sample code in implementing the below code to audit Database changes by creating a class that generates data appropriately in to the new audit logging table.

Table to audit - tabeltoaudit
New table to audit the changes - Audit_data
Sample code using DB triggers :

TRIGGER PROCEDURE FOR WRITE OF tabeltoaudit OLD BUFFER oldtabletoaudit.

DEFINE VARIABLE hOldRecord AS HANDLE NO-UNDO.
DEFINE VARIABLE hNewRecord AS HANDLE NO-UNDO.
DEFINE VARIABLE hOldField AS HANDLE NO-UNDO.
DEFINE VARIABLE hNewField AS HANDLE NO-UNDO.

DEFINE VARIABLE cChangedFields AS CHARACTER NO-UNDO.
DEFINE VARIABLE iChangedFields AS INTEGER NO-UNDO.


/* Difference between the two buffers */

BUFFER-COMPARE tabeltoaudit TO oldtabeltoaudit SAVE RESULT IN cChangedFields NO-ERROR.

IF cChangedFields <> "" THEN DO:
ASSIGN
hOldRecord = BUFFER tabeltoaudit :HANDLE
hNewRecord = BUFFER oldtabeltoaudit :HANDLE.

DO iChangedFields = 1 TO NUM-ENTRIES(cChangedFields):
CREATE Audit_data.
ASSIGN
Audit_data.rOldRecid = RECID(oldtabeltoaudit )
Audit_data.rNewRecId = RECID(tabeltoaudit )
Audit_data.cUserId = cUserId
Audit_data.dTimeSt = string(today) + " " + STRING(TIME,"HH:MM:SS")
Audit_data.cTableName = hOldRecord:NAME
Audit_data.cFieldName = ENTRY(iChangedFields, cChangedFields)
hOldField = hOldRecord:BUFFER-FIELD(ENTRY(iChangedFields, cChangedFields))
Audit_data.cOldValue = hOldField:STRING-VALUE
hNewField = hNewRecord:BUFFER-FIELD(ENTRY(iChangedFields, cChangedFields))
Audit_data.cNewValue = hNewField:STRING-VALUE.
END.
END.
 

cj_brandt

Active Member
you can use progress auditing to record the before and after values of fields in a table. You don't need to write any programs or create additional triggers.
 

Cringer

ProgressTalk.com Moderator
Staff member
You don't. Progress Auditing is a feature that is provided in 10.1A and later releases. It would have to be enabled by your DBA. It may be a good idea at this point to have a look in the documentation.
 
Top