PreviousDeploying an Application on UNIX Maintaining a DB2 DatabaseNext

Chapter 15: DB2 Applications (SQL Option)

Use SQL Option to include a DB2 application in a Net Express project.You can also maintain a DB2 database using an interactive tool, the SQL Wizard. You can compile, edit and debug your DB2 application in a DB2 environment on your PC. In addition, you can also compile, edit and debug your DB2 application against the mainframe itself, using the XDB Link technology.


You need to have installed SQL Option to do this session. We assume you are familiar with DB2 on a mainframe.

You also need to have read the chapter Start Here for the Tutorials and worked through the first session, Using Net Express, before you do this session.


15.1 Overview

The full name of this option is SQL Option for DB2. We will generally refer to it as SQL Option. It is a relational database that supports the debugging and testing of DB2 applications.

This session takes you through maintaining and running a DB2 application on your PC. It also shows how you can setup your PC to access the mainframe with the XDB Link technology, and run your DB2 application directly to the mainframe.

The demo application used in this session is a simple DB2 application that you might have downloaded from a mainframe. In this session, you get it working on your PC.

15.2 Preparation

If you have closed Net Express, open it as before. If any project window or other windows are open, close them.

15.3 Sample Session

In this session you:

15.3.1 Creating a Project

To create the project:

  1. Click New on the File menu, then select Project on the New dialog box and click OK.

  2. Highlight Empty Project entry

  3. Enter sqldemo as the name of the project

  4. Click Browse and select a suitable folder to contain the project: for example d:\Program Files\MERANT\Net Express\mfsql\demo

  5. Click Create

  6. Click Properties on the Project menu

  7. Click SQL Directives; on the ESQL Preprocessor drop-down menu, select XDB and click OK

  8. After Project directives are displayed, click OK

15.3.2 Adding Files to the Project

To add your files to the project:

  1. Click Add Files to Projecton the Project menu.

  2. In the Add Files dialog box, open the folder d:\Program Files\MERANT\\Net Express\mfsql\demo. Ensure the Files of Type field is set to All Files.

  3. Select test1.cbl, then click Add. The files are added to the project.

15.3.3 Building the Project

To build the project:

  1. Click Rebuild Allon the Project menu.

    As you saw in the chapter Using Net Express, the correct compiler is automatically called for the source files - in this case, for the COBOL files. The SQL preprocessor is called by the COBOL Compiler for each COBOL file in the ECM environment.

    The build finishes with "Rebuild complete".

15.3.4 Starting the XDB Server

To start the XDB Server on Windows NT:

  1. Go to Control Panel, and double click MERANT XDB Server for NX

  2. Click Start if the XDB Server is not running.

To start the XDB Server on Windows 95:

  1. Click SQL for DB2 on the Tools menu.

  2. Click Start Server.

15.3.5 Running the Application

To run the application:

  1. Click test1.cbl in the right-hand pane of the project window to select it.

  2. Click Run on the Animate menu.

  3. Click OK.

    The application runs. The Application Output window appears and displays the screen output from the application. This application simply inserts an employee record into a database, fetches the surname and displays it, and then deletes the record. It displays messages showing its progress.

    You can leave the Application Output window visible, as the next section uses it as well.

15.3.6 Debugging the Application

To debug the application:

  1. Ensure test1.cbl is still selected, then click Start Animating on the Animate menu.

    You see the same things happening on your screen as when running the application, but in addition a source view window appears, showing the source of test1.cbl. The application has not yet displayed its first screen in the Application Output window, because execution is paused on the first executable statement of the COBOL application. (This is the second statement in the Procedure Division, because the first, EXEC SQL DECLARE...CURSOR, is executed at compile time.

    Notice that the source you see is the original source and not the source after preprocessing.

  2. Click a few times.

    This demonstrates that you single-step a DB2 application in the same way as any other. All the same debugging features are available for a DB2 application as for any other application. We will not debug this application further, but will simply complete the run.

  3. Click .

    The application completes without debugging, and exits. As before, the Application Output window shows the messages displayed by the application.

15.3.7 Closing the XDB Server

When you have finished, you shut down the XDB Server:

  1. Click SQL for DB2 on the Tools menu.

  2. Click Stop Server.

15.3.8 Setup access to mainframe through XDB Link

To connect to the mainframe directly, without using the XDB server:

  1. Use the Gateway Profile utility to log information about the mainframe DB2 location, as follows:

    1. Click SQL for DB2 on the Options menu

    2. Click XDB LINK

    3. Login to local XDB server as user INSTALL with no password

    4. Click REGISTER

    5. Consult mainframe DBA and HELP information to fill out relevant fields.

  2. Use the Options utility to define the location and protocol you wish to use, as follows:

    1. Click SQL for DB2 on the Options menu

    2. Click CLIENT

    3. Click Security tab and enable Client Security

    4. Click Connect tab and pick DRDA as Communcation Protocol

    5. Ensure Connect Location and System Location are the value specified in GPROF utility

15.4 Before Continuing

Close the source view window and hide the Application Output window.

The Sqldemo project is used in the next session, Maintaining a DB2 Database. If you're planning to go onto that session, you can keep the project open.

If you want to take a break before going on to the next session, you can close Net Express.

Return to the Tutorials Map in the chapter Start Here for the Tutorials and choose which session to go on to next, depending on your interests.


Copyright © 2000 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousDeploying an Application on UNIX Maintaining a DB2 DatabaseNext