Configuring the File Handler for Microsoft SQL Server

As well as the database-specific information that you specify in an ACUFH configuration file, you also need to inform the File Handler of which database type it is working with when performing file handling operations. You do this by specifying the IDXFORMAT, which can be set using one of the following methods:

  • Set at compile-time, either within your source code or on the command line.
  • Set in a File Handler configuration file, which is queried at run time.

The supported values for the IDXFORMAT option are:

IDXFORMAT No: RDBMS:
18 Microsoft SQL Server
19 Oracle
20 DB2

Set the format at compile-time

Set the option within your source code using the following syntax (replacing nn with the appropriate value from the table above):

      $set IDXFORMAT"nn"
       Identification Division.
       Program-id. Dbc-demo.
       ...
       End program Dbc-demo.

Or specify the IDXFORMAT on the command line, during compilation:

Windows:

cobol Dbc-demo.cbl IDXFORMAT"nn" NOGNT"";

UNIX:

cob Dbc-demo.cbl IDXFORMAT"nn";
Note: Another method is to use the USE directive, specifying a directives file that contains the required IDXFORMAT.

Set the format at run time

Tip: Configuring the File Handler at run time enables you to use the same source code with more than one of the supported RDBMSs without the need to recompile. It also gives you greater control when setting different formats at once.

Set the option within a File Handler configuration file:

[XFH-DEFAULT]
IDXFORMAT=8
[purchdb2.dat]
IDXFORMAT=20
[purchorl.dat]
IDXFORMAT=19
Note: In the example above, purchdb2.dat file uses IDXFORMAT 20, and purchorl.dat uses IDXFORMAT 19, but all other files take the default specified in the [XFH_DEFAULT] section.

To use the configuration file at run time, you must specify it in the EXTFH environment variable:

Windows:

set EXTFH=c:\dbc\extfh.cfg

sets the file name to c:\dbc\extfh.cfg.

UNIX:

EXTFH=/home/dbc/extfh.cfg 
export EXTFH

sets the file name to /home/dbc/extfh.cfg.