21.10.2013 Views

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Internal functions<br />

Table 12.3. Context variables in the SYSTEM namespace<br />

DB_NAME Either the full path to the database or – if connecting via the path is disallowed<br />

– its alias.<br />

NETWORK_PROTOCOL The protocol used for the connection: 'TCPv4', 'WNET', 'XNET' or NULL.<br />

CLIENT_ADDRESS For TCPv4, this is the IP address. For XNET, the local process ID. For all other<br />

protocols this variable is NULL.<br />

CURRENT_USER Same as global CURRENT_USER variable.<br />

CURRENT_ROLE Same as global CURRENT_ROLE variable.<br />

SESSION_ID Same as global CURRENT_CONNECTION variable.<br />

TRANSACTION_ID Same as global CURRENT_TRANSACTION variable.<br />

ISOLATION_LEVEL The isolation level of the current transaction: 'READ COMMITTED', 'SNAPSHOT'<br />

or 'CONSISTENCY'.<br />

Return values and error behaviour: If the polled variable exists in the given namespace, its value will be returned<br />

as a string of max. 255 characters. If the namespace doesn't exist or if you try to access a non-existing variable<br />

in the SYSTEM namespace, an error is raised. If you poll a non-existing variable in one of the other namespaces,<br />

NULL is returned. Both namespace and variable names must be given as single-quoted, case-sensitive, non-NULL<br />

strings.<br />

Examples:<br />

select rdb$get_context('SYSTEM', 'DB_NAME') from rdb$database<br />

New.UserAddr = rdb$get_context('SYSTEM', 'CLIENT_ADDRESS');<br />

insert into MyTable (TestField)<br />

values (rdb$get_context('USER_SESSION', 'MyVar'))<br />

See also: RDB$SET_CONTEXT()<br />

Note<br />

RDB$SET_CONTEXT()<br />

RDB$SET_CONTEXT and its counterpart RDB$GET_CONTEXT are actually predeclared UDFs. They are listed<br />

here as internal functions because they are always present – the user doesn't have to do anything to make them<br />

available.<br />

Available in: DSQL, ESQL, PSQL<br />

Added in: 2.0<br />

152

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!