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 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, ...) [CLIETTE "cliette_name"]
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 or shared library 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. The following example specifies the variables in the ENVIRONMENT statement:
ENVIRONMENT(DTW_SQL) C:\WINNT\System32\nddb2.dll(IN DATABASE,TRANSACTION_SCOPE,USERID,PASSWORD)
If a function modifies any of its output parameters, the parameters keep their modified value after the function completes.
The name of the cliette. The cliette_name can refer to the Java Application language environment cliette, or it can be a database cliette. The cliette_name parameter is used with the CLIETTE keyword, both of which are only used with Live Connection. CLIETTE and cliette_name are optional and can be specified only for database and Java application language environments.
Syntax:
CLIETTE "DTW_JAVAPPS"
Syntax:
CLIETTE "type:db_name"
Parameters:
When Net.Data processes the initialization file, it does not load the language environment DLLs or shared libraries. Net.Data loads a language environment DLL or shared library when it first executes a function that identifies that language environment. The DLL or shared library 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 to 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) /net.data/lib/dtwsql.so ( IN DATABASE, LOGIN, PASSWORD, TRANSACTION_SCOPE, ALIGN, START_ROW_NUM, DTW_SET_TOTAL_ROWS) CLIETTE "DTW_SQL:MYDBASE" ENVIRONMENT (DTW_ORA) /net.data/lib/dtwora.so ( IN DATABASE, LOGIN, PASSWORD, TRANSACTION_SCOPE, ALIGN, START_ROW_NUM, DTW_SET_TOTAL_ROWS) ENVIRONMENT (DTW_ODBC) /net.data/lib/dtwodbc.so ( IN DATABASE, LOGIN, PASSWORD, TRANSACTION_SCOPE, ALIGN, DTW_SET_TOTAL_ROWS) ENVIRONMENT (DTW_APPLET) /net.data/lib/dtwjava.so ( ) ENVIRONMENT (DTW_JAVAPPS) /net.data/lib/dtwjavapps.so ( OUT RETURN_CODE ) CLIETTE "DTW_JAVAPPS" ENVIRONMENT (DTW_PERL) /net.data/lib/dtwperl.so ( OUT RETURN_CODE ) ENVIRONMENT (DTW_REXX) /net.data/lib/dtwrexx.so ( OUT RETURN_CODE ) ENVIRONMENT (DTW_SYSTEM) dtwsys.so ( OUT RETURN_CODE ) ENVIRONMENT (HWS_LE) dtwhws.so ( OUT RETURN_CODE )
Required: Each ENVIRONMENT statement must be on a single line.