|
esqlconv |
|
|
esqlconv is a tool to convert the COBOL/DB2 E/SQL to COBOL/Oracle and COBOL/MS SQL Server compatible sources. It performs several types of manipulation (AKA process) on the code: each manipulation process may be separately activated with the command line options. Some processes require the XML description of DB2 tables used in the processed programs. This files may be obtained with xddlconv. Target selection The target database for the code conversion must be selected. The currently supported database types:
The target must be selected with -target option specifying one of the following values:
Process description SQLCODE process This process handles the SQLCODE comparisons, replacing the DB2 SQLCODEs with the corresponding Oracle one. This process may be propagated to all the fields "infected" by SQLCODE: when SQLCODE is move on another field, this one is processed as SQLCODE, and therefore also comparisons on this are managed. Example IF SQLCODE = 100 becomes IF SQLCODE = 1403 Note: the SQLCODE values conversion table may be externally provided, using option -s. Furthermore, using option -create, ESQLCONV, may generate this file this table, in order to provide you a skeleton file to customize with your desired values. I.e. esqlconv -creare -s <sqlcodes_file_to_generate> -target mssql TIMESTAMP process It replaces the DB2 special register CURRENT TIMESTAMP with LOCALTIMESTAMP, and the system table SYSIBM.SYSDUMMY1 with DUAL. SETTSTAMP process It replaces the SET :host-var = TIMESTAMP statements with corresponding Oracle or SQL Server ones, and it replaces the system table SYSIBM.SYSDUMMY1 by DUAL for Oracle only. Example EXEC SQL becomes (for Oracle) EXEC SQL becomes (for SQL Server) EXEC SQL RMSCHEMA process It removes the scheme identifier from table names. Example EXEC SQL becomes EXEC SQL CURSOR process It replaces the dash (-) character with underscore (_) in the cursor names. Example EXEC SQL DECLARE CUR-SELCS CURSOR FOR becomes EXEC SQL DECLARE CUR_SELCS CURSOR FOR DATE process Handles the DB2 DATE fields, to allow their correct management with the target database. Please note that DB2 automatically recognizes the format of dates contained in the host variables, while Oracle and SQL Server require an explicit date format qualification (i.e. TO_DATE). Whenever necessary, the process inserts the the HTTODATE PL/SQL function that emulates the DB2 behaviour. If an indicator is defined, the function HTTODATE2 is used. It processes the E/SQL statements replacing: Example EXEC SQL becomes EXEC SQL Process the E/SQL statements replacing:
Furthermore, it is possible to change the behaviour of this process, providing the options -noHTTODATE (which inhibits the usage of HTTODATE) e -convDate, which enables the conversion in CHAR format of the output dates (for SELECT and WHERE) using the function TO_CHAR (for Oracle) and CONVERT (for SQL Server). Of course, this process is based on the identification of DATE fields for the processed tables, whose DDL must be correctly parsed by xddlconv and provided to ESQLCONV (option -l). Example 1 (HTTODATE) EXEC SQL becomes EXEC SQL Example 2 (DATE sum) EXEC SQL becomes EXEC SQL TIME process Process the E/SQL statements managing fields previously defined as TIME in DB2. It applies the following changes:
Depending on the conversion options provided to xddlconv, TIME fields may be converted into DATE or CHAR(8) datatypes. Therefore, the behaviour of this process varies depending on the conversion strategy applied by xddlconv. By default, esqlconv manages TIME fields as CHAR(8). Providing the "-td" option on command line, it handles TIME fields as DATE (TIME to DATE). Note: All the operands used in WHERE clauses, are always managed as CHAR. Example 1 - SELECT with -td (TIME to DATE) EXEC SQL becomes EXEC SQL Example 2 - INSERT with -td (TIME to DATE) EXEC SQL becomes EXEC SQL Example 3 - UPDATE without -td (TIME to CHAR(8)) EXEC SQL becomes EXEC SQL Of course, this process is based on the identification of DATE fields for the processed tables, whose DDL must be correctly parsed by xddlconv and provided to ESQLCONV (option -l). TIMESTAMP process Process the E/SQL statements managing fields previously defined as TIMESTAMP in DB2. It applies the following changes:
For Oracle, the standard behaviour of this process is based on the management of DB2 TIMESTAMP types as Oracle TIMESTAMP types. For SQL Server, this is meaningless because, on this target DB, TIMESTAMP is always converted as CHAR(26). OPTIMIZE process Replaces the OPTIMIZE FOR clause with /*+ FIRST ROWS(n) */ EXEC SQL becomes EXEC SQL RMFETCHONLY process Removes the FOR FETCH ONLY and FOR READ ONLY clauses. ALL process Activates all processes available. Output structure The source programs are only read, and the modified version is stored in the output repository, defined with the -o option. The output repository structure depends on the source input: each file processed is stored in the output repository in a directory with the same name of the one from which the object has been loaded. Output files esqlconv processes the programs: coybooks and includes are handles as program components, and therefore they can not be managed standalone. esqlconv generates the following files: Modified program It is the converted program, and It has the same name of the source one. Modified copybooks and includes Each copybook and include file processed. Listing It is stored in the same directory of the modified program, with extension .lst. It contains the result of copybook/include expansion. Log file It is stored in the same directory of the modified program, with extension .log. It contains a summary of operation performed, including:
Each row/column coordinate refers to the listing. Options
Date/Time conversion format The format specification fields (i.e. ESQL-TIME-FMT, ESQl-DATE-FMT) are provided by the host variables defined in the include file ESQLINC0.cpy. This include must be created by the user. Example (ESQLINC0.cpy for Oracle) 01 ESQLINC0. Example (ESQLINC0.cpy for SQL Server) 01 ESQLINCO. A sample ANT target <target name="ol_db2"> |