Setting environment variables for xfODBC

This topic describes the methods you can use to set environment variables for xfODBC. The method you should use depends on your operating system, the configuration of xfODBC (client/server or stand-alone), and which programs you want the setting to affect.

On Windows and OpenVMS, environment variables for use by xfODBC must be set system-wide; Unix, however, does not support system-wide settings so you must set environment variables before starting the program or service that uses them, such as with a shell script.

You can set environment variables in the following ways:

 

This topic includes the following sections:

 

This topic describes the methods you can use to set environment variables. The method you should use depends on your operating system, the configuration of xfODBC (client/server or stand-alone), and which programs you want the setting to affect.

Note

For a full list of xfODBC environment variables, see Appendix A: Environment Variables.

Setting system-wide variables

On Windows and OpenVMS, environment variables for services and ODBC-enabled applications must be set system wide. On Unix, which doesn’t support system-wide environment variables, you must set environment variables before starting the program or service that uses them. (Often it’s convenient to do this with a shell script.)

To set a system-wide environment variable,

Setting variables in the environment

When we use the term “the environment” to describe where an environment variable should be set, it could be any of the following:

Setting environment variables from a command prompt

Environment variables set at a command prompt are temporary. They exist only in the current environment and do not apply when you leave the environment. In the following examples, the environment variable DATA is set to a directory named “dat”, a subdirectory of the GENESIS_HOME directory.

SET DATA=%GENESIS_HOME%\dat
DATA=$GENESIS_HOME/dat; export DATA
DEFINE DATA GENESIS_HOME:[DAT]

Setting environment variables in a batch file, shell script, or DCL command file

For dbcreate and DBA, you can set environment variables from a batch file (Windows), shell script (Unix), or DCL command file (OpenVMS). The advantage of this method is that the variables are set only when necessary. Moreover, they are no longer in effect once the current process terminates—for example, when you close a Command Prompt window in Windows, log off in OpenVMS, or exit a shell on Unix. (Note that on Unix, an environment variable must be exported to the shell for it to be available to additional programs run from the shell.) This is a particularly good way to store variables that need to be set only for system catalog generation.

1. Using a text editor, create a batch file, shell script, or DCL command file and define xfODBC environment variables in the file using the standard syntax. For example:
set SODBC_CNVOPT=1
SODBC_CNVOPT=1 ;export SODBC_CNVOPT
DEFINE/SYS SODBC_CNVOPT 1

(/SYS is optional. It sets the environment variable as a system-wide logical on OpenVMS.)

2. From the command line, run the batch file, script, or DCL command file.
3. After running the file, run dbcreate or DBA from the command line in the same environment.

On Unix and OpenVMS, your xfODBC distribution includes shell scripts (setodbc and startnet) or a DCL command file (STARTNET.COM) you can use to specify environment variables. Note the following:

SODBC_ODBCNAME=1; export SODBC_ODBCNAME
nohup vtxnetd -p1958 log &
sleep 1 

Setting environment variables in a connect file

You can use your connect file to define environment variables for the xfODBC driver. These definitions are read by the xfODBC driver when connecting to a database and remain in effect for the duration of the connection. Environment variables set in the connect file are used to locate data files and set some data access options. Note the following:

XFDBTUT=C:\Program Files\Synergex\SynergyDE\connect\synodbc\dat
CUST=c:\data\customer.ism
ORDER=c:\data\orders.ism
PLANTS=c:\data\plants.ism

The following connect file examples set an environment variable named XFDBTUT (which is used in the sample Synergy database and set in the sample connect file):

dictsource "C:\Program Files\Synergex\SynergyDE\connect\synodbc\dict\"
datasource ";C:\\Program Files\\Synergex\\SynergyDE\\connect\\synodbc\\dat;"
XFDBTUT=C:\Program Files\Synergex\SynergyDE\connect\synodbc\dat
dictsource  /usr/synergyde/connect/synodbc/dict
datasource ;/usr/synergyde/connect/synodbc/dat;
XFDBTUT=/usr/synergyde/connect/synodbc/dat
dictsource  DKA300:[SYNERGYDE.CONNECT.SYNODBC.DICT]
datasource ;DKA300:[SYNERGYDE.CONNECT.SYNODBC.DATA];
XFDBTUT=DKA300:[SYNERGYDE.CONNECT.SYNODBC.DATA] 
Note

If you set SYNCENTURY and SYNBASEDATE, you must set them in the connect file if the connect file is on the server.

For more information on connect files, see Setting Up a Connect File.

Setting environment variables in the xfODBC Setup window

The xfODBC Setup window has two fields you can use to set environment variables used for data access (not system catalog generation).

For information on the xfODBC Setup window and the syntax for setting environment variables in these fields, see Adding a user or system DSN.

Setting environment variables in an environment setup file

An environment setup file is one way to store and activate all the data environment variables you need when connecting to a Synergy database. An environment setup file is a text file you write; it typically has an .ini file extension and is placed in the GENESIS_HOME directory, though these are not requirements. Note the following:

XFDBTUT=%CONNECTDIR%synodbc\dat

Setting environment variables in synergy.ini (Windows)

Because the DBA program, xfdba.dbr, is a Synergy application, you can set environment variables used by DBA in synergy.ini. Synergy.ini is read every time you run dbr.

Note

The xfODBC driver and dbcreate don’t recognize environment variables set in synergy.ini.

Below is an example of an environment variable set in synergy.ini. Note an environment variable can be used as part of another environment variable’s definition.

SODBC_DBA=%CONNECTDIR%synodbc\dba

Setting environment variables in opennet.srv (Windows)

Environment variables used by the SQL OpenNet server can be defined in the opennet.srv file. For example, the distributed opennet.srv file defines GENESIS_HOME before starting the Synergy/DE OpenNet Server service (SynSQL):

GENESIS_HOME=%CONNECTDIR%synodbc\
.
.
.
vtxnetd.exe -k67834 -p1958 log

This sets the environment variable and then launches the service, overriding any system-set variable. For more information on opennet.srv, see Customizing the opennet.srv file.

Setting environment variables in System Properties (Windows)

On Windows, you can set system-wide environment variables from the System Properties dialog. From Windows Control Panel, select System, then select Advanced System Settings to display the System Properties dialog. On the Advanced tab, click the Environment Variables button, and then click the New button below the System variables area.

Setting environment variables in log-in files (Unix and OpenVMS)

On Unix, you can set environment variables in the log-in file (.profile if you’re using Bourne or Korn shell, .login if you’re using C shell). After setting an environment variable on Unix, you must export it unless you have the “auto-export” feature turned on in your shell. (Refer to your Unix reference manual for details on auto-export. Not all Unix systems offer this option.)

For example:

GENESIS_HOME=$CONNECTDIR/synodbc
export PATH GENESIS_HOME

On OpenVMS, you can set environment variables (logicals) in your user log-in file or in the system-wide log-in file located in SYS$MANAGER. You can also set system-wide environment variables in SYS$MANAGER:CONNECT_STARTUP.COM, but remember that this file is replaced every time you install Synergy. The following is an example of an environment variable set in a log-in file:

$ DEFINE GENESIS_HOME SYNERGYDE$ROOT:[CONNECT.SYNODBC]