Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » SQL Anywhere Server - SQL Reference » System procedures » Alphabetical list of system procedures

xp_getenv system procedure

Returns the value of an environment variable.

Syntax
xp_getenv( environment_variable )
Parameters
  • environment_variable

    Use this VARCHAR(8000) parameter to specify the environment variable. This parameter is case insensitive on Windows operating systems and case sensitive on all other operating systems, independent of the case sensitivity of the database. The default value is NULL.

Returns

This function returns a LONG NVARCHAR value.

Remarks

If the environment variable specified is NULL or not set, NULL is returned.

Privileges

You must have EXECUTE privilege on the system procedure, as well as the SERVER OPERATOR system privilege.

The GETENV feature must be enabled for the connection (-sf server option).

Side effects

None

Example

The following example uses the xp_getenv system procedure to return the value of the environment variable PATH.

SELECT CAST( xp_getenv( 'PATH' ) AS LONG VARCHAR );

The following example uses the xp_getenv and sa_split_list system procedures to return the value of the Windows environment variable PATH as a list. Use ':' as the separator character on Unix operating systems.

CALL sa_split_list( CAST( xp_getenv( 'PATH' ) AS LONG VARCHAR ), ';' );

The following example uses the environment variable NONEXISTENT, which is assumed to not exist. Therefore, the query is expected to return NULL.

SELECT xp_getenv( 'NONEXISTENT' );