Sets an application context name, attribute name, and attribute value, defined by the attributes of an application, for a specified user session.
set_appcontext ("context_name", "attribute_name", "attribute_value")
context_name – a row that specifies an application context name, saved as the datatype char(30).
attribute_name – a row that specifies an application context name, saved as the datatype char(30)
attribute_value – a row that specifies an application attribute value, saved as the datatype char(2048).
This example creates an application context called CONTEXT1, with an attribute ATTR1 that has the value VALUE1:
select set_appcontext ("CONTEXT1", "ATTR1", "VALUE1")
--------------- 0
This example shows an attempt to override the existing application context. The attempt fails, returning -1:
select set_appcontext("CONTEXT1", "ATTR1", "VALUE1")
-------------- -1
This example shows how set_appcontext can include a datatype conversion in the value:
declare@val numeric select @val = 20 select set_appcontext ("CONTEXT1", "ATTR2", convert(char(20), @val))
------------ 0
This example shows the result when a user without appropriate permissions attempts to set the application context. The attempt fails, returning -1:
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.
set_appcontext cannot override the values of an existing application context. To assign new values to a context, remove the context and re-create it with new values.
set_appcontext saves attributes as char datatypes. If you create an access rule that must compare the attribute value to another datatype, the rule should convert the char data to the appropriate datatype.
All arguments in this function are required.