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 decribed in Using Language Environments and the language environment interface are described in Net.Data Language Environment Reference.
Net.Data requires that an ENVIRONMENT statement exist in the Net.Data initialization file for a language environment before you can invoke the language environment.
Net.Data specifies several variables that affect the way in which Net.Data language environments interpret calls to functions that are defined in FUNCTION blocks. The settings of these variables must be passed to a language environment to have an effect.
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. On OS/400, 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.
The parameters are passed in the parm_data_array field of the dtw_lei structure, following the parameters that are specified in the FUNCTION block definition. (See Net.Data Language Environment Reference for information about these structures.)
You must define these parameters as configuration variables or as variables in your macro file 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 INI 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.
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 ( )
Each ENVIRONMENT statement must be on a single line.