Admin Production rocket
Current Publication

Compiling DB2 Programs with HCO

NetExpress Bookshelf Help V5.1 WrapPack 1
Rocket® Net Express™ (formerly a product of Micro Focus or formerly a product of Open Text) documentation, created before Rocket Software acquired certain products from OpenText, may include outdated references to "Micro Focus" or "OpenText", both of which are trademarks of OpenText or its affiliates. Rocket Software is not affiliated with Micro Focus or OpenText and has since rebranded these products as Rocket® products. You may also encounter outdated links in this documentation. If you do, please contact Rocket Support (support@rocketsoftware.com) for assistance.

Chapter 9: Compiling DB2 Programs with HCO

This chapter describes the compiling of programs using the DB2 External Compiler Module (ECM).

Overview

The DB2 External Compiler Module allows programs checked with CHARSET(EBCDIC) directive to access SQL tables using DB2 Universal Database. The DB2 ECM generates code to convert all character data (columns defined as CHAR or VARCHAR) from EBCDIC to ANSI before storing it in DB2 Universal Database tables and conversely converts it from ANSI to EBCDIC on all retrievals from DB2 Universal Database tables.

This means that other products such as Microsoft Excel can still be used to access data stored in the tables.

Warning!

The only time the DB2 ECM may have problems is where character columns are defined as being FOR BIT DATA. The data stored in the column is not necessarily ANSI character data to begin with. In this case, the DB2 ECM still generates the code to convert the column. Therefore, results can be unpredictable.

DDL Processing

The DB2 ECM has the ability to handle DB2 syntax DDL statements within programs. DDL statements are converted automatically to DB2 Universal Database syntax. See the chapter Product Specifications for more details on which statements are supported and limitations.

Collating Sequence For Data

If you are merging data from multiple sources using EBCDIC, you need access to SQL tables that are stored in databases created with the correct collating sequence. To get the data to come out in the correct sort sequence or to be included correctly when specified in WHERE clauses, all tables that are used with this pre-processor must be created in a database that specifies the EBCDIC collating sequence. See the chapter Create Database for more details on creating databases with EBCDIC collating sequences.

Invoking the DB2 ECM

When you compile your programs, the DB2 ECM must be invoked to add the additional code needed to do the ANSI to EBCDIC translations as well as translate the EXEC SQL statements into database API calls.

For complete information on compiling, see the Compiling section in the chapter DB2 of your Database Access book.

Using DB2 UDB V7.1 and Later

In DB2 UDB V7.1, the size of the program identifier (PID) string increased from 40 bytes to 162 to enable the use of COLLECTION-ID's longer than eight characters. Because the PID is stored in each DB2 application when it is compiled, the DB2 ECM needs to generate a different PID structure depending on whether you are using DB2 UDB V7.1 or later.

For more information, see the UDB-VERSION DB2 Directive Option section in the chapter DB2 of your Database Access book.

Error Messages When Compiling Program

There are two significant differences when using DB2 Universal Database versus mainframe DB2. The first is that you have to connect to the database before you can compile a program. With mainframe DB2 you can pre-compile a program without DB2 being active. The second major difference is that all columns and tables referenced in the program must be created in the database before a program can be compiled whereas with mainframe DB2 they don't have to be. In both cases, the mainframe DB2 pre-compiler uses the DECLARE TABLE information in an SQL INCLUDE copybook to determine valid syntax as opposed to DB2 Universal Database which uses DB2 system catalog information to validate statements. In either case, a SQL Error could result using DB2 Universal Database.

In addition, if invalid SQL syntax is encountered while compiling your program, a SQL error is also generated for each statement in error. The text that is associated with the SQL error is displayed using the following format:

DB0100e SQLnnnnnn error-text

Where DB indicates error resulted from DB2 ECM (the error number is always 0100); e is the error severity, and SQLnnnnnn is the SQL error code (nnnnnn may vary between 2 and 6 characters).


Copyright © 2007 Micro Focus (IP) Ltd. All rights reserved.