Demonstration Applications

A number of ODBC demonstration applications are supplied.

Before you can use any of the demonstration applications, you need to have installed at least one ODBC driver, and created DSNs to use with the demonstrations.

Some of the demonstration applications expect that a table called EMP exists on the database to which you are connecting.

The OpenESQL demonstration applications all produce a console log displaying their progress and, possibly, query results. They all terminate on receipt of an error, after displaying an error message.

Mainframe Samples – Windows Environment

You can run these samples from the Mainframe Samples Browser. To start the Mainframe Samples Browser, click Start > All Programs > Micro Focus Enterprise Developer > Samples > Mainframe Samples

Note: On Windows 8, Windows 10, and Windows Server 2012, you use the Start screen to invoke programs. To start the Mainframe Samples Browser on Windows 8, Windows 10, or Windows Server 2012, go to the Start screen and click the Mainframe Samples tile.

All ODBC samples are listed on the Show unmanaged only list in the Mainframe Samples Browser.

The source files are located in subdirectories under %PUBLIC%\Documents\Micro Focus\Enterprise Developer\Samples\Mainframe\SQL\OpenESQL\JCLCallingSP.

Each sample application comes with a Readme file to explain how to use the application.

OESQL - JCL Calling SP Multi-project by Data Name
Walks you through the process of invoking a native COBOL program using JCL, and calling programs and stored procedures in multiple assemblies using data names.
OESQL - JCL Calling SP Multi-project by Literal
Walks you through the process of invoking a native COBOL program using JCL, and calling programs and stored procedures in multiple assemblies using literals.
OESQL - JCL Calling SP Single-project by Data Name
Walks you through the process of invoking a native COBOL program using JCL, and calling programs and stored procedures in a single assembly using data names.
OESQL - JCL Calling SP Single-project by Literal
Walks you through the process of invoking a native COBOL program using JCL, and calling programs and stored procedures in a single assembly using literals.

Visual COBOL Samples – Windows Environment

You can run these samples from the Visual COBOL Samples Browser. To start the Visual COBOL Samples Browser, click Start > All Programs > Micro Focus Enterprise Developer > Samples > Visual COBOL Samples.

Note: On Windows 8, Windows 10, and Windows Server 2012, you use the Start screen to invoke programs. To start the Samples Browser on Windows 8, Windows 10, or Windows Server 2012, go to the Start screen and click the Visual COBOL Samples tile.

All ODBC samples are listed on the Show unmanaged only list in the Visual COBOL Samples Browser.

The source files are located in subdirectories under %PUBLIC%\Documents\Micro Focus\Enterprise Developer\Samples\Eclipse\COBOL\SQL\openesql.

OESQL - Getting Started
A simple example of using static SQL with OpenESQL, performing a variety of SQL operations. It also demonstrates the use of different styles of CONNECT statement.
OESQL - Behavior
Connects to a data source name LocalServer using the Microsoft SQL Server ODBC driver. To do this, see the Help topic To set up an ODBC data source name.

The program creates and populates a table used by behavior.cbl and behavsub.cbl. After the table is created, we show how the BEHAVIOR directive makes the same ambiguous COBOL cursor declaration read only in behavior.cbl and updateable in behavsub.cbl.

You can verify this by looking at the trace file OpenESQLTrace.processID.log, in the project directory. The log file is generated by the TRACELEVEL directive in behavior.cbl.

OESQL - Catalog
Displays an SQL Data Sources dialog. Enter or select a name and click on OK. A Login dialog is displayed. Enter a login name of "admin", leave the password blank and click on OK. Performs three data dictionary queries and outputs the results.
OESQL - Connect
Prompts for a data source, user name and password. Enter the data source name you created, a user name of "admin" and leave the password blank (just press return). Four tests which perform connects and disconnects using a variety of syntax options are run. The fifth test displays an SQL Data Sources dialog. Select the appropriate name from the Machine Data Source list and click on OK. A Login dialog is displayed. Enter a login name of "admin", leave the password blank and click on OK. The fifth test is run and the program terminates.
OESQL - Dynamic
A simple example of using dynamic SQL with OpenESQL, performing a variety of SQL operations. It is functionally equivalent to the code used by the Getting Started sample.
OESQL - Get Diagnostics
Shows how to use Get Diagnostics EXEC SQL calls to get diagnostic information from the OpenESQL runtime. This demo works with a Microsoft SQL Server but can also work with IBM DB2 LUW and Oracle.
OESQL - LOB Data Types
Shows how to use OpenESQL to insert and select large objects (LOBs), and shows OpenESQL working with LOB columns within a Microsoft SQL Server table. Includes instructions for working with IBM DB2 LUW and Oracle.
OESQL - Select
Connects to the sample database and prompts for a customer code. Enter BLUEL (as the prompt suggests). Two fields from the customer record are displayed and the program prompts for another customer code. Just press the return key this time. The program prompts for a region. Enter CA (as the prompt suggests). The program displays a list of customers in that region and prompts for another region. This time, press the return key to terminate the program.
OESQL - Whenever
Illustrates the use of EXEC SQL WHENEVER syntax to aid with error handling. It also uses the MFSQLMESSAGETEXT variable for retrieving error messages longer than the 70 bytes available within the SQLERRMC field.

UNIX Environment

The source files for these samples are located in $COBDIR/demo/openesql.

Each sample program comes with a progName.txt file to explain how to use the program.

catalog.cbl
The file catalog.cbl is an OpenESQL demonstration program that shows how to use the ODBC catalog functions from COBOL.
dynquery.cbl
The file dynquery.cbl is an OpenESQL demonstration program that shows how to use dynamic SQL functions from COBOL. It provides the capability for the user to enter any SQL statement and the program will execute them. It shows how to prepare a SQL statement and how to use the SQLDA structure to retrieve data from columns when the type of the column is not known when the program is compiled.

If you are accessing the EMP table described above, a sample query would be:

select FIRST_NAME, LAST_NAME, HIRE_DATE, SALARY from EMP
static.cbl
The file static.cbl is an OpenESQL demonstration program that shows how to use basic SQL functions from COBOL. It demonstrates the use of INSERT, UPDATE, DELETE, SELECT INTO and SELECT using a cursor. It also shows the use of COMMIT and ROLLBACK.
testconn.cbl
The file testconn.cbl is an OpenESQL demonstration program that shows how to use different formats of the CONNECT and DISCONNECT statements.