This section provides step-by-step instructions for sqlizing your data based on the Sqlize Tutorial (Driver\ctree.cobol\tutorials\sqlize\). It assumes you have already set up the environment where you will run the COBOL application using FairCom RTG.
You can obtain the current XDD structure from an existing table using ctutil-sqlinfo.
FairCom RTG provides tools to help you fine-tune your installation to overcome these problems. In particular, see Troubleshooting Data Conversion Errors.
The process of sqlizing consists of three major steps for the end user (the tutorial below includes extra steps for clarity):
Extract the XDD from COBOL (step 2 in the tutorial below).
Sqlize it using ctutil (step 4 in the tutorial below).
Use SQL to access the database (step 6 in the tutorial below).
The SQLIZEEXAMPLE program prints out information about membership cards satisfying a partial card number request. The program itself can create the required file if the file does not exist, however it does not populate the file.
Compile the SQLIZEEXAMPLE.CBL program: iscc SQLIZEEXAMPLE.CBL
Extract the XDD from SQLIZEEXAMPLE.CBL by running xddgen: C:\FairCom\vx.x.x.RTG\winX64\Tools\cmdline\XDDGEN\xddgen.exe SQLIZEEXAMPLE.CBL
Create empty FairCom RTG files using either the COBOL program or the XDD.
You can execute the COBOL program one time to create the COBOL files (.DAT and .IDX): iscc -ze SQLIZEEXAMPLE.CBL
Or you can use the XDD to create the file, using ctutil-make: ctutil.exe -make CARDFILE CARDFILE.xdd
Sqlize it, using ctutil–sqlize and the XDD: ctutil.exe -sqlize CARDFILE CARDFILE.xdd ADMIN ctreeSQL -rule=rules.xml
Populate the table using the SQL script Tutorial.sql: isql.exe -s Tutorial.sql -u ADMIN -a ADMIN ctreeSQL
Run the COBOL program again and count the records. You can now use SQL to query the multi-record data.
A few tips:
Use the ACUCOBOL compiler option ‑f4 to automatically generate an XFD file. In most cases, FairCom RTG can readily use this information to automatically sqlize the table upon creation.
The FairCom RTG ctree.conf file allows automatic sqlizing with the <sqlize> configuration option as long as a valid COBOL XFD or FairCom RTG XDD file is available. Uncomment this in the provided ctree.conf file for Tutorial1.
You’ll find compiler specific directives (*>>XDD WHEN) in the CARDFILE.FD source module. Review this module which provides a modestly complex usage of COBOL redefines, resulting in multiple SQL “tables” from a single COBOL table. Be sure to run xddgen over this module to create a valid XDD file.