Migrating from Pro*COBOL

This chapter explains how to precompile and run with GixSQL programs written for Oracle Pro*COBOL, either on an Oracle database or on PostgreSQL.

Connecting

Pro*COBOL programs connect with CONNECT :USR IDENTIFIED BY :PWD, optionally USING :DB-STRING with a SQL*Net alias. With GixSQL, the USING operand is a GixSQL connection string (Connection strings), not an Oracle alias.

NoteTo be verified

Behavior of CONNECT ... IDENTIFIED BY without USING (mode 4 of the grammar is “unsupported”).

COMMIT WORK RELEASE and ROLLBACK WORK RELEASE end the transaction and close the connection.

Running on PostgreSQL

Programs written for Oracle can run on PostgreSQL, provided their SQL is compatible. The orafce extension provides many Oracle functions (NVL, DECODE, TO_DATE…). Its oracle schema must come before pg_catalog in the search path, so that oracle.to_date is used instead of the PostgreSQL to_date:

pgsql://dbserver/db?default_schema=myschema,oracle,pg_catalog,public
NoteTo be completed

Common SQL differences: ROWNUM, outer joins (+), SYSDATE, empty strings and NULL, DUAL, sequences (seq.NEXTVAL).

Feature comparison

The table follows the chapters of the Pro*COBOL Programmer’s Guide.

Pro*COBOL feature GixSQL
Declare section accepted, not required
EXEC SQL INCLUDE supported
Conditional precompilation (EXEC ORACLE IFDEF) not supported
CONNECT ... IDENTIFIED BY, AT supported
CONNECT :USR-PWD (user/password in one item) not supported
COMMIT, ROLLBACK, SAVEPOINT, RELEASE supported
SET TRANSACTION, LOCK TABLE passed to the database
Host variables, indicator variables supported
VARCHAR / VARYING variables (2-byte length) supported with -N 2
Datatype equivalencing (EXEC SQL VAR) partial: see Host variables and datatypes
EXEC SQL TYPE not supported
Universal ROWID fetched as character strings (Oracle)
SELECT INTO, INSERT, UPDATE, DELETE supported
Cursors, WHERE CURRENT OF supported
Scrollable cursors (FETCH PRIOR, ABSOLUTE…) not supported
Embedded PL/SQL blocks (EXEC SQL EXECUTE BEGIN ... END; END-EXEC) not supported
Host tables (arrays) not supported
SQLCA supported
ORACA not supported
WHENEVER (SQLERROR, SQLWARNING, NOT FOUND) supported
WHENEVER ... DO, STOP not supported
Dynamic SQL methods 1, 2, 3 supported
Dynamic SQL method 4 (SQLDA), ANSI dynamic SQL (descriptors) not supported
Runtime contexts, multithreading not supported
LOB statements not supported
Precompiler options see the correspondence below
NoteTo be verified

Each “not supported” line above, in particular SET TRANSACTION, EXEC SQL TYPE, scrollable cursors, WHENEVER ... DO, and the generic passthrough of unknown statements.

Precompiler options

procob option gixpp equivalent
INAME, ONAME -i, -o
INCLUDE -I
FORMAT=TERMINAL, IRECLEN --code-end-col
MODE=ANSI (SQLCODE 100 on “no record”) default
MODE=ORACLE (SQLCODE 1403) --no-rec-code 1403
PICX=VARCHAR2 -P varchar
PICX=CHARF -P charf (default)
VARCHAR=YES level-49 groups are always recognized
SQLCHECK, USERID no equivalent: no semantic checking
RELEASE_CURSOR, HOLD_CURSOR, MAXOPENCURSORS no equivalent
NoteTo be verified

Check MODE and PICX against the Pro*COBOL documentation.