RDB$SET_CONTEXT()
Creates, sets or clears a variable in one of the user-writable namespaces
INTEGER
RDB$SET_CONTEXT ('<namespace>', <varname>, <value> | NULL)
<namespace> ::= USER_SESSION | USER_TRANSACTION
<varname>   ::= A case-sensitive quoted string of max. 80 characters
<value>     ::= A value of any type, as long as it's castable
                to a VARCHAR(255)
| Parameter | Description | 
|---|---|
| namespace | Namespace | 
| varname | Variable name.Case-sensitive.Maximum length is 80 characters | 
| value | Data of any type provided it can be cast to  | 
The USER_SESSION and USER_TRANSACTION namespaces are initially empty.A user can create and set variables with RDB$SET_CONTEXT() and retrieve them with [fblangref50-scalarfuncs-get-context].The USER_SESSION context is bound to the current connection, the USER_TRANSACTION context to the current transaction.
- 
When a transaction ends, its USER_TRANSACTIONcontext is cleared.
- 
When a connection is closed, its USER_SESSIONcontext is cleared.
- 
When a connection is reset using ALTER SESSION RESET, theUSER_TRANSACTIONandUSER_SESSIONcontexts are cleared.
The function returns 1 when the variable already existed before the call and 0 when it didn’t.To remove a variable from a context, set it to NULL.If the given namespace doesn’t exist, an error is raised.Both namespace and variable names must be entered as single-quoted, case-sensitive, non-NULL strings.
| Note | 
 | 
select rdb$set_context('USER_SESSION', 'MyVar', 493) from rdb$database
rdb$set_context('USER_SESSION', 'RecordsFound', RecCounter);
select rdb$set_context('USER_TRANSACTION', 'Savepoints', 'Yes')
  from rdb$database