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

Examples

This example creates an application context called CONTEXT1, with an attribute ATTR1 that has the value VALUE1:

Example 1

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

Example 2

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

Example 3

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

Usage