set_appcontext

Description

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.

Syntax

set_appcontext(“context_name, “attribute_name”, “attribute_value”)

Parameters

context_name

is a row that specifies an application context name. It is saved as the datatype char(30).

attribute_name

is a row that specifies an application context attribute name. It is saved as the datatype char(30).

attribute_value

is a row that specifies and application attribute value. It is saved as the datatype char(30).

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

Attempting to override the existing application context created causes:

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

Example 2

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

Example 3

Shows the result when a user without appropriate permissions attempts to set the application context.

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

Usage

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

The permission checks for set_appcontext differ based on your granular permissions settings.

Granular permissions enabled

With granular permissions enabled, you must have select permission on set_appcontext to execute the function.

Granular permissions disabled

With granular permissions disabled, you must be a user with sa_role, or have select permission on set_appcontext to execute the function.

See also

Documents 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