Tutorial: Generate and Embed an SQL Program

Now that the SQL query has been generated, you can use OpenESQL Assistant to generate a generic COBOL program and embed the query right into it.

Before attempting this tutorial, you must complete the following tutorials in the order listed:
  • Tutorial: Create a SQL Server Database
  • Tutorial: Create and Configure an Eclipse Project
  • Tutorial: Set OpenESQL Assistant Configuration Options
  • Tutorial: Catalog a Connection
  • Tutorial: Build and Test a Query
Generate a Generic SQL Program
  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.

Embed the Generic SQL Program into the Eclipse Project
We're now ready to embed our generic SQL program into the current Eclipse project.
  1. From the Auxiliary Code tab, click Add Query to temporary fileAdd Query to temporary file.
  2. Click Save temporary file to diskSave temporary file to disk, and browse to the directory contains the Program1.cbl file you created earlier.
  3. Select program1.cbl; then click Save. A prompt appears, asking if you want to replace the current file.
  4. Click Yes.
  5. Change to the Eclipse IDE. A prompt appears to tell you that the file contents have changed.
  6. Click Yes. The program now appears in the Eclipse IDE program editor. Eclipse automatically saves the file.
Embed the SQL Query
Next, you embed the generated 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 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.