Generate and Embed an SQL Program and Query

Walks you through the process of using the OpenESQL Assistant to generate a generic COBOL SQL program, embedding the program into an existing COBOL program in the OESQLAsst project, and adding the generated SQL query to the program.

Generate a generic SQL Pprogram

  1. In the OpenESQL Assistant, click the Auxiliary Code tab.
  2. From the Statement Type drop-down list, select Generic SQL Program.

    OpenESQL Assistant generates a generic SQL program in the Generated Auxiliary Code box on the Auxiliary Code tab.

Replace the code in Program1.cbl with the code generated by the OpenESQL Assistant

  1. From the Auxiliary Code tab, click Add Query to temporary file (Add Query to temporary file).

    This copies the generated code to the clipboard.

  2. Click Save temporary file (Save temporary file to disk), and browse to your project work directory, which contains the Program1.cbl file created earlier.
  3. Select program1.cbl, then click Save. A prompt appears, asking if you want to replace the current file.
  4. Click Yes.

Embed the SQL Query into program1.cbl

  1. From the OpenESQL Assistant, click the Query tab; then click Add Query to temporary fileAdd Query to temporary file.
  2. In Eclipse, in the COBOL Editor, place the cursor on the line just after the comment:
    *> Put your program logic/SQL statements here
  3. Right-click; then select Paste.

    OpenESQL Assistant inserts the query into the program

  4. Click File > Save to save Program1.cbl.