Visual COBOL provides a number of demonstration applications
for OpenESQL ODBC.
You can access these via the
Visual COBOL Samples Browser. For instructions on how to start
the Visual COBOL Samples Browser, see
To start the Samples Browser.
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 ODBC 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.
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\Visual COBOL\Samples\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.