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 provided by the ACF.
set_appcontext(“context_name, “attribute_name”, “attribute_value”)
select set_appcontext ("CONTEXT1", "ATTR1", "VALUE1")
--------------- 0
Attempting to override the existing application context created causes:
select set_appcontext("CONTEXT1", "ATTR1", "VALUE1")
------------- -1
declare@numericvarchar varchar(25) select @numericvar = "20" select set_appcontext ("CONTEXT1", "ATTR2", convert(char(20), @numericvar))
------------ 0
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.
For more information on the ACF see Row-Level Access Control in System Administration Guide.
ANSI SQL – Compliance level: Transact-SQL extension.
The permission checks for set_appcontext differ based on your granular permissions settings.
Granular Permissions | Description |
---|---|
Enabled | With granular permissions enabled, you must have select permission on set_appcontext to execute the function. |
Disabled | With granular permissions disabled, you must be a user with sa_role, or have select permission on set_appcontext to execute the function. |