set_appcontext

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")

Parameters

Examples

Example 1 Creates an application context called CONTEXT1, with an attribute ATTR1 that has the value VALUE1:

select set_appcontext ("CONTEXT1", "ATTR1", "VALUE1")
---------------
0

Example 2 Shows an attempt to override the existing application context. The attempt fails, returning -1:

select set_appcontext("CONTEXT1", "ATTR1", "VALUE1")
--------------
-1

Example 3 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

Example 4 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

Usage