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 built-in function that the Application Context Facility (ACF) provides. For more information on the Application Context Facility see "Row Level Access Control" in the System Administration Guide.

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(2048).

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 the following:

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

SQL92 – Compliance level: Transact-SQL extension.

Permissions

Permissions depend on the user profile and the application profile, stored by ACF.

See also

Functions get_appcontext, list_appcontext, rm_appcontext