Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Mailing Lists -> Oracle-L -> Re[4]: Cobol redefine in SQL

Re[4]: Cobol redefine in SQL

From: Jonathan Gennick <>
Date: Thu, 27 Nov 2003 11:29:26 -0800
Message-ID: <>

Thursday, November 27, 2003, 1:24:53 PM, Jared Still ( wrote: JS> The value of part of a string in a file was used to determine what JS> was in the rest of the string, and where it was. Very, very ugly.

Back in the day, this sort of thing was done, a lot. It's ugly when viewed through today's lens of random access disk files and relational databases. It's defensible, I think, if you wind the clock back 30 years. I really, really, really need to work on a book, and then an article, this afternoon, but let me try to explain, at least a bit. Basically, when sending data to someone, it was common to generate a tape with data written sequentially. For example:

    Customer #1
    Order #1

    Lineitem #1
    Lineitem #2
    Lineitem #3

    Order #2
    Lineitem #1
    Lineitem #2
    Customer #2

    Order #1
    Lineitem #1

If you think in terms of *sequential* processing, you can begin to see where this sort of arrangement makes some amount of sense. You can process all the customers and orders and lineitems by making one pass through the tape.

On the other hand, if you wrote the tape in the form:

    Customer #1
    Customer #2

    Order #1 for customer #1
    Order #2 for customer #2

    Line item #1 for order #1 for customer #1

Well! Imagine if I handed you this tape and asked you to generate a report of customers and their orders. You'd need to unload the tape to disk, break the data into three files, sort it all, merge it together. Oh, and did I tell you, you don't have enough disk space to do that.

Government data used to be sent out on tape using many record formats thrown together into one file. It's not at all yucky to deal with, but you certainly do *not* want to apply that same organization to data in a relational database.

JS> COBOL redefines sound exactly like that, and if so, I stand JS> by my condemnation. yuck.

Here's a simple example that might help to illustrate some of the magic:

01 user-command pic x(20).

01 help-command redefines user-command.

   05 filler pic x(4).

      88 needs-help value 'help'.
   05 filler pic x(16).    

01 display-command redefines user-command.

   05 filler pic x(7).

      88 display-emp value 'display'.
   05 filler pic x(x).
   05 display-emp-id pic 99999.
   05 filler pic x(7).    

01 print-command redefines user-command.

   05 filler pic x(5).

      88 print-emp value 'print'.
   05 filler pic x(x).
   05 print-emp-id pic 99999.
   05 filler pic x(9).

Given the above, you can now write code like this:

IF display-emp THEN

   CALL display-employee USING display-emp-id

ELSE IF print-emp THEN
   CALL print-employee USING print-emp-id
ELSE IF needs-help THEN
   CALL print-some-help.

This may not be the best example, but in this case the acceptable commands and their formats are driven by definitions in working-storage. You can easily change from using 'display 99999' to 'show employee 99999' simply by tweaking your working-storage definitions.

Best regards,

Jonathan Gennick --- Brighten the corner where you are * 906.387.1698 *

Join the Oracle-article list and receive one article on Oracle technologies per month by email. To join, visit, or send email to and include the word "subscribe" in either the subject or body.

Please see the official ORACLE-L FAQ:
Author: Jonathan Gennick

Fat City Network Services    -- 858-538-5051
San Diego, California        -- Mailing list and web hosting services
To REMOVE yourself from this mailing list, send an E-Mail message
to: (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Thu Nov 27 2003 - 13:29:26 CST

Original text of this message