SQL Code Generation Options

Before you begin compiling, testing, and executing your HCOPG code, consider what you want HCOPG to do for you.

To convert all mainframe SQL in my programs such that it works with AWS PostgreSQL
Set the TARGETDB SQL compiler directive option to either POSTGRESQL or PGSQLAWS, and set the DIALECT SQL compiler directive option to MAINFRAME.
To convert all mainframe SQL in my programs such that it works with PostgreSQL GDG community edition
Set the TARGETDB SQL compiler directive option to PGSQL, and set the DIALECT SQL compiler directive option to MAINFRAME.
Note: Support for PostgreSQL GDG community edition is in Early Adopter Release status.
Only to embed SQL into the generated code
To have HCOPG simply embed SQL into the generated code, no additional compiler directive options are required. This is the default behavior.
Note: You can also use DIALECT=MIXED to convert selected EXEC SQL statements in the code. To fully enable compile-time checking of converted SQL statements using PostgreSQL, set the DB, PASS and QUALIFIER directives along with DIALECT=MAINFRAME or DIALECT=MIXED. For additional information, see the SQL Statement Prefixes for DIALECT Directive and the Application Progression from DB2 to PostgreSQL topics.

The following table provides a quick reference to the SQL compiler directive options that affect code generation. For complete information on each, see the appropriate Reference topic.

SQL Compiler Directive Option Generation Specifics Advantages
None (default) SQL remains embedded in object code Simplicity
DIALECT1 Converts DB2 SQL statements that are not compatible with PostgreSQL into equivalent pgSQL statements in most cases.
  • You do not need to convert DB2 statements to pgSQL
  • You can change the default schema at compile time using the QUALIFIER SQL compiler directive option.
1 For additional information, see also the SQL Statement Prefixes for DIALECT Directive and the Building Applications topics.