An ENVIRONMENT statement configures a language environment. A language environment is a component of Net.Data that Net.Data uses to access a data source such as a DB2 database or to execute a program written in a language such as REXX. Net.Data provides a set of language environments, as well as an interface that allows you to create your own language environments. These language environments are described in Using Language Environments and the language environment interface is described in Net.Data Language Environment Interface Reference.
Net.Data requires that an ENVIRONMENT statement for a particular language environment exist before you can invoke that language environment.
Net.Data for OS/400 does not require an ENVIRONMENT statement for language environments that are shipped with Net.Data. However, if a language environment statement is encountered, it overrides the default that Net.Data uses. It is recommended that ENVIRONMENT statements for Net.Data supplied language environments not be added to the Net.Data configuration file.
You can associate variables with a language environment by specifying the variables as parameters in the ENVIRONMENT statement. Net.Data implicitly passes the parameters that are specified on an ENVIRONMENT statement to the language environment as macro variables. To change the value of a parameter that is specified on an ENVIRONMENT statement in the macro, either assign a value to the variable using the DTW_ASSIGN() function or define the variable in a DEFINE section. Important: If a macro variable is defined in a macro but is not specified on the ENVIRONMENT statement, the macro variable will not be passed to the language environment.
For example, a macro can define a DATABASE variable to specify the name of a database at which an SQL statement within a DTW_SQL function is to be executed. The value of DATABASE must be passed to the SQL language environment (DTW_SQL) so that the SQL language environment can connect to the designated database. To pass the variable to the language environment, you must add the DATABASE variable to the parameter list of the environment statement for DTW_SQL.
The sample Net.Data initialization file makes several assumptions about customizing the setting of Net.Data environment configuration statements. These assumptions may not be correct for your environment. Modify the statements appropriately for your environment.
To add or update an ENVIRONMENT statement:
ENVIRONMENT statements have the following syntax:
ENVIRONMENT(type) library_name (parameter_list, ...)
Parameters:
The name by which Net.Data associates this language environment with a FUNCTION block that is defined in a Net.Data macro. You must specify the type of the language environment on a FUNCTION block definition to identify the language environment that Net.Data should use to execute the function.
The name of the service program containing the language environment interfaces that Net.Data calls.
The service program name is specified with the .SRVPGM extension.
The list of parameters that are passed to the language environment on each function call, in addition to the parameters that are specified in the FUNCTION block definition.
To set and pass the variables in the parameters list, define the variable in the macro.
You must define these parameters as configuration variables or as variables in your macro before executing a function that will be processed by the language environment. If a function modifies any of its output parameters, the parameters keep their modified value after the function completes.
When Net.Data processes the initialization file, it does not load the language environment service programs. Net.Data loads a language environment service program when it first executes a function that identifies that language environment. The service program then remains loaded for as long as Net.Data is loaded.
Example: ENVIRONMENT statements for Net.Data-provided language environments
When customizing the ENVIRONMENT statements for your application, add the variables on the ENVIRONMENT statements that need to be passed from your initialization file to a language environment or that Net.Data macro writers need to set or override in their macros.
On OS/400, ENVIRONMENT statements are not required for Net.Data language environments and are not recommended. However, this example shows some of the default ENVIRONMENT statements that Net.Data uses.
1 MACRO_PATH /WWW/MACRO;/QSYS.LIB/WWW.LIB/MACRO.FILE 2 INCLUDE_PATH /WWW/MACRO;/QSYS.LIB/WWW.LIB/MACRO.FILE 3 EXEC_PATH /QSYS.LIB;/QSYS.LIB/WWW.LIB 4 ENVIRONMENT(DTW_REXX) /QSYS.LIB//QTCP.LIB/QTMHREXX.SRVPGM ( ) 5 ENVIRONMENT(DTW_SQL) /QSYS.LIB/QTCP.LIB/QTMHSQL.SRVPGM (IN DATABASE, LOGIN, PASSWORD, TRANSACTION_SCOPE, SHOWSQL, DB_CASE, RPT_MAX_ROWS, START_ROW_NUM, DTW_SET_TOTAL_ROWS, OUT DTWTABLE, SQL_CODE, TOTAL_ROWS) 6 ENVIRONMENT(DTW_SYSTEM) /QSYS.LIB/QTCP.LIB/QTMHSYS.SRVPGM ( )
Required: Each ENVIRONMENT statement must be on a single line.