Product Documentation

c-treeRTG COBOL Edition User's Guide

Previous Topic

Next Topic

Step-by-Step Sqlizing Instructions

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 c-treeRTG.

The process of sqlizing consists of three major steps for the end user (the tutorial below includes extra steps for clarity):

  1. Extract the XDD from COBOL (step 2 in the tutorial below).
  2. Sqlize it using ctutil (step 4 in the tutorial below).
  3. 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.

  1. Compile the SQLIZEEXAMPLE.CBL program:
    iscc SQLIZEEXAMPLE.CBL
  2. Extract the XDD from SQLIZEEXAMPLE.CBL by running xddgen:
    C:\FairCom\vx.x.x.RTG\winX64\Tools\cmdline\XDDGEN\xddgen.exe SQLIZEEXAMPLE.CBL
  3. Create empty c-treeRTG files using either the COBOL program or the XDD.
    1. You can execute the COBOL program one time to create the COBOL files (.DAT and .IDX):
      iscc -ze SQLIZEEXAMPLE.CBL
    2. Or you can use the XDD to create the file, using ctutil -make:
      ctutil.exe -make CARDFILE CARDFILE.xdd
  4. Sqlize it, using ctutil –sqlize and the XDD:
    ctutil.exe -sqlize CARDFILE CARDFILE.xdd ADMIN ctreeSQL -rule=rules.xml
  5. Populate the table using the SQL script Tutorial.sql:
    isql.exe -s Tutorial.sql -u ADMIN -a ADMIN ctreeSQL
  6. 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, c-treeRTG can readily use this information to automatically sqlize the table upon creation.
  • The c-treeRTG ctree.conf file allows automatic sqlizing with the <sqlize> configuration option as long as a valid COBOL XFD or c-treeRTG 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.

TOCIndex