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.
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 LOCATION variable to specify the location name of the remote DBMS at which an SQL statement within a DTW_SQL function is to be executed. The value of LOCATION must be passed to the SQL language environment (DTW_SQL) so that the SQL language environment can connect to the designated remote DBMS. To pass the variable to the language environment, you must add the LOCATION variable to the parameter list of the environment statement for DTW_SQL.
There are also variables that you set as configuration variables in the initialization file, and that you can override in a macro. For example, if you want a macro to override the default settings of the DB2PLAN and DB2SSID variables when the SQL language environment is invoked, include them on the ENVIRONMENT statement for DTW_SQL.
ENVIRONMENT statement changes: If you are migrating from a previous version of Net.Data, make the following changes in the ENVIRONMENT statement section:
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 DLL containing the language environment interfaces that Net.Data calls.
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 DLLs . Net.Data loads a language environment DLL when it first executes a function that identifies that language environment. The DLL 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.
ENVIRONMENT (DTW_SQL) dtwsql (IN LOCATION, DB2SSID, DB2PLAN, TRANSACTION_SCOPE) ENVIRONMENT (DTW_ODBC) odbcdll (IN LOCATION, TRANSACTION_SCOPE) ENVIRONMENT (DTW_APPLET) appldll () ENVIRONMENT (DTW_PERL) perldll () ENVIRONMENT (DTW_FILE) filedll () ENVIRONMENT (DTW_REXX) rexxdll () ENVIRONMENT (DTW_SYSTEM) sysdll ()
Required: Each ENVIRONMENT statement must be on a single line.