Created On:  19 September 2011


When migrating programs precompiled with Oracle's Pro*COBOL preprocessor to OpenESQL there is an error reported on the following statement when it is in the working-storage section of the program.


The error reported by OpenESQL is:

     "ES0114 Statement only allowed in the PROCEDURE DIVISION."

If the statement is moved to the procedure division then OpenESQL does not display the error message.  Why is this happening?


The problem is that this is an Oracle Pro*COBOL extension and it is not supported in OpenESQL either in the working-storage section or in the procedure division.  The reason you see the error is because OpenESQL tries to be very flexible in what it allows since it is designed to work with just about any data source and it only recognizes as much SQL syntax as it has to.

The preprocessor determines that the statement isn’t a data declaration, but in the procedure division it just assumes it’s server-specific syntax and passes it through at runtime. If you actually try and execute the statement it will fail.  If you turn on SQL(CHECK) then it will fail at compile time.

You will need to remove this type of Oracle syntax and use SQL TYPE IS in the host variable declaration.