Sets an application context name, attribute name, and attribute value for a user session, defined by the attributes of a specified application. set_appcontext is a built-in function that the Application Context Facility (ACF) provides.
set_appcontext(“context_name, “attribute_name”, “attribute_value”)
is a row that specifies an application context name. It is saved as the datatype char(30).
is a row that specifies an application context attribute name. It is saved as the datatype char(30).
is a row that specifies and application attribute value. It is saved as the datatype char(30).
Creates an application context called CONTEXT1, with an attribute ATTR1 that has the value VALUE1.
select set_appcontext ("CONTEXT1", "ATTR1", "VALUE1")
--------------- 0
Attempting to override the existing application context created causes the following:
select set_appcontext("CONTEXT1", "ATTR1", "VALUE1")
------------- -1
Shows set_appcontext including a datatype conversion in the value.
declare@numericvarchar varchar(25) select @numericvar = "20" select set_appcontext ("CONTEXT1", "ATTR2", convert(char(20), @numericvar))
------------ 0
Shows the result when a user without appropriate permissions attempts to set the application context.
select set_appcontext("CONTEXT1", "ATTR2", "VALUE1")
-------------- -1
set_appcontext returns 0 for success and -1 for failure.
If you set values that already exist in the current session, set_appcontext returns -1.
This function cannot override the values of an existing application context. To assign new values to a context, remove the context and re-create it using new values.
set_appcontext saves attributes as char datatypes. If you are creating an access rule that must compare the attribute value to another datatype, the rule should convert the char data to the appropriate datatype.
All the arguments for this function are required.
ANSI SQL – Compliance level: Transact-SQL extension.
Permissions depend on the user profile and the application profile, stored by ACF.
For more information on the ACF see “Row-level access control” in Chapter 11, “Managing User Permissions” of the System Administration Guide.
Functions get_appcontext, list_appcontext, rm_appcontext