COBOL to Oracle PL/SQL Migration

SQLines provides tools to help you convert existing COBOL stored procedures and programs to Oracle PL/SQL.

   # Convert a single file
  ./sqlines -sl=cobol -s=db2 -t=oracle -in=cobol.cbl
 
  # Convert multiple files
  ./sqlines -sl=cobol -s=db2 -t=oracle -in=*.cbl -out=out_dir/

See more command line options.

To run the conversion in SQLines Studio, edit sqlines.cfg and set -sl=cobol option.

Migration Reference

Language Elements

Converting language elements:

COBOL Oracle PL/SQL
1 * comment text * in 7 column -- comment text
2 VAR-NAME Dash (-) sign in identifiers VAR_NAME Converted to underscore (_)

Program Options

Converting COBOL program options:

COBOL Oracle PL/SQL
1 CBL RENT Shared code Not required, removed

Compiler Directives

Converting COBOL compiler directives:

COBOL Oracle PL/SQL
1 $SET P(COBSQL) | PREPROCESS(COBSQL) END-C ENDP Using SQL statements Not required, removed

IDENTIFICATION DIVISION

Converting IDENTIFICATION division and its paragraphs:

COBOL Oracle PL/SQL
1 PROGRAM-ID. name. Program name CREATE OR REPLACE PACKAGE name IS
2 AUTHOR. name. Program author Commented
3 DATE-WRITTEN. date. Program creation date Commented
4 DATE-COMPILED. date. Program compilation date Commented

ENVIRONMENT DIVISION

Converting ENVIRONMENT division and its paragraphs:

COBOL Oracle PL/SQL
1 CONFIGURATION SECTION. System environment Removed
2 INPUT-OUTPUT SECTION. File and I/O paragraphs Removed

INPUT-OUTPUT SECTION. paragraphs:

COBOL Oracle PL/SQL
1 FILE-CONTROL. File-control paragraph Removed

FILE-CONTROL paragraph:

COBOL Oracle PL/SQL
1 SELECT value ASSIGN TO value
ORGANIZATION IS LINE SEQUENTIAL
STATUS IS value.
Define file mapping Removed

DATA DIVISION

Converting DATA division and its sections:

COBOL Oracle PL/SQL
1 FILE SECTION. Fields of records for used files
2 WORKING-STORAGE SECTION. Static program variables Package variables
3 LINKAGE SECTION. Input and output program variables Package procedure parameters

Data types and formats:

COBOL Oracle PL/SQL
1 PIC X(n) Character string VARCHAR2(n)
PIC XXXXX VARCHAR2(5)
2 PIC 9(n) Integer number NUMBER(n)
3 PIC S9(n) Signed integer number NUMBER(n)

DB2 COBOL stored procedure data types:

DB2 SQL DB2 COBOL Mapping Oracle PL/SQL
1 name VARCHAR(n) 01 name.
49 length PIC S9(4).
49 name PIC X(n).
name VARCHAR2(n)

SQL declarations:

COBOL Oracle PL/SQL
1 EXEC SQL INCLUDE SQLCA END-EXEC. SQL communication area Not required, removed
2 EXEC SQL DECLARE cur CURSOR
FOR select_stmt END-EXEC.
Cursor declaration CURSOR name IS select_stmt;

PROCEDURE DIVISION

Converting PROCEDURE division and its statements:

COBOL Oracle PL/SQL
1 IF bool_expr [THEN] … [ELSE …] [END-IF] IF statement IF bool_expr THEN … [ELSE …] END IF;
2 MOVE value TO var Assigmnent statement var := value