HP3000-L Archives

October 1998, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Richard Gambrell <[log in to unmask]>
Reply To:
Richard Gambrell <[log in to unmask]>
Date:
Sat, 17 Oct 1998 17:57:31 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (91 lines)
Glenn,
Don't take it too hard, at least it *did* work on your real test, unlike the
following Cobol code that could never have worked in any real test (some
names have been changed to protect the guilty vendor in the non-MPE non-Image
world - and is all too typical of their code):

Delaration:
      03 VAR-BATCH-TRANS-DATE    PICTURE X(006).
      03 BATCH-TRANS-DATE       PICTURE X(006).

One of these is used to read data from an external file.
Then, there is the following code to apply a Y2K pivot fix to the date (and
there is no documentation in the program as the expected date format):

     EXEC SQL
        SELECT SUBSTR(:VAR-BATCH-TRANS-DATE,1,7)||'20'||
               SUBSTR(:VAR-BATCH-TRANS-DATE,8,2)
        INTO   :BATCH-TRANS-DATE
        FROM DUAL
        WHERE SUBSTR(:VAR-BATCH-TRANS-DATE,8,2) < :CENTURY-PIVOT
      END-EXEC.

      IF BATCH-TRANS-DATE EQUAL SPACES
       EXEC SQL
          SELECT SUBSTR(:VAR-BATCH-TRANS-DATE,1,7)||'19'||
                 SUBSTR(:VAR-BATCH-TRANS-DATE,8,2)
          INTO   :BATCH-TRANS-DATE
          FROM DUAL
          WHERE SUBSTR(:VAR-BATCH-TRANS-DATE,8,2) > :CENTURY-PIVOT
          OR    SUBSTR(:VAR-BATCH-TRANS-DATE,8,2) = :CENTURY-PIVOT
        END-EXEC.


Cheers and have a good weekend,
Richard

Glenn Cole wrote:
>
> D-oh!  Late Friday is probably not a good time for hasty conclusions. :/
> (Not that any other time is much better....)
>
> I wrote that parsing
>
> >         john,brown,ca,95014
>
> with
>
> >         setvar  first_name      word( line,,1,x)
> >         setvar  last_name       word( line,,1,x,x )
> >         setvar  state           word( line,,1,x,x )
> >         setvar  zip             word( line,,1,x,x )
>
> worked.  It doesn't, as was pointed out to me in a private email.
>
> What happened was that I parsed
>
>           setvar  line  "this is a test"
>
> with the above word() expressions and THAT worked, but only because
> leading spaces are skipped while other leading delimiters are not.
> (The space between "this" and "is" becomes a "leading" space for
> the second invocation of word() in the code above.)
>
> So, in the example shown, 'x' never gets beyond the first comma,
> and all fields after 'first_name' are set to the empty string "".
>
> The following works fine:
>
> >       setvar  first_name      word( line,,1,x)
> >       setvar  last_name       word( line,,1,x,x+1 )
> >       setvar  state           word( line,,1,x,x+1 )
> >       setvar  zip             word( line,,1,x,x+1 )
>
> Many thanks to Jeff "The Man" Vance for bringing this to my attention. :)
>
> --Glenn "hip deep in CI functions and on-the-fly command files" Cole
>   Software al dente, Inc.
>   [log in to unmask]
>
> .......................................................................
>
> Item Subject: cc:Mail Text

--
Richard Gambrell
Database Administrator and Consultant to Computing Services
University of Tennessee at Chattanooga, Dept. 4454
113 Hunter Hall, 615 McCallie Ave. Chattanooga, TN 37403-2598
UTC e-mail: [log in to unmask]   phone: 423-755-4551
Home e-mail: [log in to unmask]

ATOM RSS1 RSS2