Can anyone out there help me with Database Connectors, and the IDXFORMAT?
I have a question about the $SET IDXFORMAT command that I place before my select statement.
I know that "21" is for an Indexed file, and that "18" is for the SQL Indexed file, but are their any IDXFORMATS for sequential files or Sort files that won't be in the SQL db?
Not all of our files will be stored in the Database (especially if we can't store sequential files), and I was also wondering if ALL of my files in my COBOL program need to have the $SET IDXFORMAT command so the database connector knows what kind of file it is??
Can sequential files be written and processed by SQL?
Also, does anyone know of some training videos or something I can read besides the MicroFocus documentation?
Thanks!
Can anyone out there help me with Database Connectors, and the IDXFORMAT?
I have a question about the $SET IDXFORMAT command that I place before my select statement.
I know that "21" is for an Indexed file, and that "18" is for the SQL Indexed file,
Database Connector allows you to use standard COBOL I-O statements to access RDBMS, such as Oracle, DB2, MS SQL Server, and ODBC, and you would need to specify the proper IDXFORMAT type (18 for SQL Server, 19 for Oracle, 20 for DB2, and 22 for ODBC) in their respective SELECT clause.
By default, Visual COBOL sets IDXFORMAT to 8, and this is used for your other indexed files. You may change the default by setting the compiler directive IDXFORMAT(value).
but are their any IDXFORMATS for sequential files or Sort files that won't be in the SQL db?
Not all of our files will be stored in the Database (especially if we can't store sequential files), and I was also wondering if ALL of my files in my COBOL program need to have the $SET IDXFORMAT command so the database connector knows what kind of file it is??
Can sequential files be written and processed by SQL?
The file handler takes care of all indexed and sequential files, and Database Connector comes in place when you want to use COBOL I-O statements to access RDBMS mentioned above.
Also, does anyone know of some training videos or something I can read besides the MicroFocus documentation?
Not that I am aware of.
Can anyone out there help me with Database Connectors, and the IDXFORMAT?
I have a question about the $SET IDXFORMAT command that I place before my select statement.
I know that "21" is for an Indexed file, and that "18" is for the SQL Indexed file, but are their any IDXFORMATS for sequential files or Sort files that won't be in the SQL db?
Not all of our files will be stored in the Database (especially if we can't store sequential files), and I was also wondering if ALL of my files in my COBOL program need to have the $SET IDXFORMAT command so the database connector knows what kind of file it is??
Can sequential files be written and processed by SQL?
Also, does anyone know of some training videos or something I can read besides the MicroFocus documentation?
Thanks!
Hi Amy,
The Database Connectors feature in Visual COBOL allows COBOL programs to use standard COBOL (Indexed) File I-O syntax to create and work with tables stored in RDBMS databases. This support is available for:
|
IDXFORMAT No:
|
RDBMS:
|
|
18
|
Microsoft SQL Server
|
|
19
|
Oracle
|
|
20
|
DB2
|
|
22
|
ODBC (allows support for additional RDBMS's, including PosgreSQL, that can be accessed via ODBC)
|
The above list is a subset of all of the IDXFORMAT options available via the Micro Focus File Handler - these are specifically the ones that relate to using Database Connectors. For example, the IDXFORMAT 21 you mentioned is not for Database Connectors; it is for working with local files stored in RM file format. For a list of all available IDXFORMAT settings, please see this page in the documentation:
Specifying which IDXFORMAT will be used for a particular file defined in the COBOL program can be done at compile time, by using Compiler Directives. The $SET IDXFORMAT statement you mentioned is an example of this.
Another option for specifying the desired IDXFORMAT for a file is to provide configuration information at runtime to the Micro Focus File Handler. This is done using a text file, called an External File Handler configuration file.
Here is one example of the contents of such a file; let's say I name it "myextfh.cfg".
[XFH-DEFAULT]
BASENAME=ON
[MYFILE]
IDXFORMAT=18
At runtime, you point to this file with the environment variable EXTFH.
On Unix/Linux: export EXTFH=myextfh.cfg
On Windows: set EXTFH=myextfh.cfg
The above specifies that if the file being accessed by COBOL has a base name of "MYFILE", the file handler will attempt to use Database Connectors to access the file as a table in Microsoft SQL Server.
There are many options for the contents of an External File Handler configuration file, the above is just an example. Please see the section in the documentation File Handler Configuration for more information. Using one of the options for controlling file handler settings would allow you to have different IDXFORMATS for different indexed files, without inserting $set statements in your code.
Finally, Database Connectors does not work with files defined with sequential file *syntax* in a COBOL program. So if you have a COBOL program that is written to access a sequential file, with a SELECT statement syntax similar to:
SELECT MYSEQFILE
ASSIGN TO "MYSEQFILE"
organization is sequential
FILE STATUS MY-STAT.
then the program will not use Database Connectors for that file; the file would be accessed as a standard local sequential file.
Hope this helps.