Xbasic

a5Helper_writeToAuditingLog Function

Syntax

dim result as c = a5Helper_writeToAuditingLog(cn as SQL::Connection, operationType as C, dataJSON as C, pkFields as C, pkValue as C [, comment as C])

Arguments

cnSQL::Connection

An open connection to the database where the audit table is located.

operationTypeCharacter

The type of operation being performed. Can be 'UPDATE', 'INSERT', or 'DELETE'.

dataJSONCharacter

JSON text object that contains the old and new data value for the fields being modified.

pkFieldsCharacter

The name of the primary key field in the table being modified.

pkValueCharacter

The value for the primary key for the record in the table being modified.

commentCharacter

An optional comment to include in the audit log, such as the name of the script that performs the update.

Description

Writes an entry to the audit table in an application with auditing enabled.

Discussion

If auditing is turned on for a web project, will update the auditing log. 'dataJSON' has the data for field old/new values. To get dataJSON, call a5Helper_getAuditInfoFromSQLStatement() before the CRUD operation occurs (for Update and Delete).

Example

dim cn as sql::Connection
cn.open("::Name::Northwind")
dim args as sql::arguments
args.add("primaryKey","ALFKI")
args.add("title","Manager")


dim sql as c
sql = "update Customers set ContactTitle = :title where CustomerID = :primaryKey"

'capture the BEFORE update values
dim dataJson as c
dataJson = a5Helper_getAuditInfoFromSQLStatement(cn,sql,args.xml)

flag = cn.Execute(sql,args)

'write to the auditing table
a5Helper_writeToAuditingLog(cn,"Update",dataJson,"CustomerID","ALFKI")

This function does not support multi-row updates.

Limitations

Used in Web Applications Configured to use an Audit Table

See Also