Start of change

PUTENV scalar function

The PUTENV scalar function changes the value of an environment variable for the current job.

The function is implemented using the putenv() API. The result is similar to using the Add Environment Variable (ADDENVVAR) or Change Environment Variable (CHGENVVAR) CL commands.

The function requires that Option 13 (System Openness Includes) of the IBM i operating system is installed.

Authorization: See Note below.

Read syntax diagramSkip visual syntax diagramPUTENV( ENVIRONMENT_VARIABLE_NAME =>  environment-variable-name ,ENVIRONMENT_VARIABLE_VALUE =>  environment-variable-value)
The schema is SYSTOOLS.
environment-variable-name
An expression that returns the name of an environment variable. If it does not exist, it will be created.
environment-variable-value
An expression that returns the value to assign to environment-variable-name.
The result of the function is an integer. The function returns the following values:
0
The operation was successful.
non-zero
The operation failed. The return value corresponds to the errno value from the API which describes the failure.

Note

This function is provided in the SYSTOOLS schema as an example of how to embed a C interface within SQL PL code. Similar to other Db2® for i provided tools within SYSTOOLS, the SQL source can be extracted and used as a model for building similar helper functions, or to create a customized version within a user-specified schema.

Services provided in SYSTOOLS have authorization requirements that are determined by the interfaces used to implement the service. To understand the authority requirements, extract the SQL for the service and examine the implementation.

Example

  • Set the value of MY_ENVVAR for the current job.
    VALUES SYSTOOLS.PUTENV('MY_ENVVAR', 'My job''s value for the environment variable');
End of change