Tuesday, January 27, 2009

Tip #37 – Using ApplicationID with SQL

The ApplicationId property was added to Advantage in version 8.0. This property allows developers to specify an ID for their application when connecting to Advantage. By default this property is set to the name of the executable which is connecting (i.e. ARC.exe).

This property can be set and read using SQL statements. To set the ApplicationID use the sp_SetApplicationID system procedure. The ID can be retrieved using the sp_GetApplicationID system procedure or using the ApplicationID() SQL scalar function. See the examples below:

// Set the ApplicationID to Chris
EXECUTE PROCEDURE sp_SetApplicationID('Chris')
 
// Retrieve the ApplicationID
EXECUTE PROCEDURE sp_GetApplicationID()
 
// Using the ApplicationID SQL Scalar Function
SELECT APPLICATIONID() FROM system.iota

The ApplicationID will also be reported by the remote management utility in ARC. You can also get management information with SQL statements see Management via SQL. The ApplicationID is displayed on the connected users tab.

ARC Management Utility

3 comments:

Anonymous said...

Chris...can you give an example or two of how the ApplicationID could be put to good use? How are other users using this value?

Anonymous said...

Why is it that when in ARC, I can't see this column (Application ID). The last one I see is Terminal Client Address ( using 8.10.0.26 ). Is it a setting somewhere? Lynne

Chris Franz said...

The ApplicationID can be very useful if you are logging activity in your database. It can assist in identifying which applications are modifying data in the tables.

Lynne,
The ApplicationID was added to the ADS_MGMT_USER_INFO structure in version 9.0 of Advantage so it is not available from the 8.x management functions. You can still use sp_GetApplicationID or the ApplicationID scalar function with version 8.x