Now that the SQL query has been generated, you can use OpenESQL Assistant to generate a generic SQL program and embed the
query right into it.
- Requirements
- 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
-
- In the OpenESQL Assistant, click the
Auxiliary Code tab.
- 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.
- Copy the Generic SQL Program to
Program1.cbl
- You can now replace the code in
Program1.cbl with the generated SQL program code.
- From the
Auxiliary Code tab, click
Add Query to temporary file.
This copies the generated code to the clipboard.
- Click
Save temporary file, and browse to the directory contains the
Program1.cbl file you created earlier.
- Select
program1.cbl; then click
Save. A prompt appears, asking if you want to replace the current file.
- Click
Yes.
Back in the COBOL editor in Eclipse, the
Program1.cbl file is updated with the new code, and the file is saved in the project.
- Embed the SQL Query
- Next, you embed the generated SQL query into
Program1.cbl.
- From the OpenESQL Assistant, click the
Query tab; then click
Add Query to temporary file.
- In
Eclipse, in the COBOL Editor, place the cursor on the line just after the comment:
*> Put your program logic/SQL statements here
- Right-click; then select
Paste.
OpenESQL Assistant inserts the query into the program
- Click
File > Save to save
Program1.cbl.