Database
  Home arrow Database arrow Page 3 - Building an Audit Trail for Your Data
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE

Building an Audit Trail for Your Data
By: Michael Kleane
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 41
    2004-02-25

    Table of Contents:
  • Building an Audit Trail for Your Data
  • Creating Audit Tables
  • Passing Table Names
  • Creating the Audit Triggers
  • Making the Trigger Code Readable
  • Auditing Tips/Techniques

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Building an Audit Trail for Your Data - Passing Table Names


    (Page 3 of 6 )

    A table name is retrieved from the first cursor. This table name is then passed as a parameter to the second cursor which obtains column information from the data dictionary. Some data type checking is required so the proper length can be specified, or, in the case of NUMBER, a precision and scale.  

    To audit the data, three columns are added to the audit table: aud_action captures the type of DML performed, aud_timestamp receives the system date, and aud_user records the current user performing the action.

    The resulting build_script can be immediately executed from the current script.

    SPOOL OFF
    @build_audit_tables.sql

    If the schema contained the single unaudited table described below:

    desc audit_test
     Name Null?  Type
    TEST_VARCHAR2VARCHAR2(30)
    TEST_CHAR   CHAR(4)
    TEST_LONG  LONG
    TEST_NUMBER NUMBER(2
    TEST_NUMBER2  NUMBER
    TEST_DATE               DATE

    The script build_audit_tables.sql will look something like this:

    CREATE TABLE audit_test$AUD(
    test_varchar2VARCHAR2(30), 
    test_char CHAR(4),
     test_long LONG,
    test_numberNUMBER(2,0), 
    test_number2NUMBER(38,0), 
    test_date                  DATE, 
    aud_action CHAR(3),aud_timestamp DATE,             aud_user VARCHAR2(30))/
                                                                       
                                                            
                                                          
                                                                     

    More Database Articles
    More By Michael Kleane


       · Hi ,The content is well written and innovative.A charger to readers...
       · With a Web App the user of the database maybe the same (asp.net user) no matter who...
     

    DATABASE ARTICLES

    - Converting Your Excel Worksheet into a Worki...
    - Excel Reference
    - Database Programming in C# with MySQL : Usin...
    - Formatting Techniques for Data Access from E...
    - Data Access from Excel VBA
    - Generating a Multiple Table Crystal Report u...
    - ADO and the Command Object
    - On Wiring Up an ADO Data Control
    - Reading and Writing to Files on the Intranet
    - Using ADO Record to Create and Navigate Intr...
    - Using Data Access Pages to Access Data on a ...
    - Using ADO with the SQL Native Client
    - ADO`s Stream Object
    - Opening a Record Object Referencing an Open ...
    - Introducing Jasper (SQL Anywhere 10 Beta)





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT