For Programmers: Free Programming Magazines  


Home > Archive > Cobol > May 2004 > MicroFocus Cobol: use of group names in DB definitions









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author MicroFocus Cobol: use of group names in DB definitions
Valdir Jorge

2004-05-13, 11:30 am

Hi!

We are doing a proof of concept project to see what are the issues when
converting from VMS Cobol to Microfocus Cobol under Linux. One of the
problems we're facing now is that Microfocus Cobol doesn't seem to like
group names when defining a DB table. For example, we have a table
called t01_table that is defined in VMS Cobol like this:

01 t01-table-rec.
05 t01-prime.
10 t01-tabno pic x(03).
10 t01-de-key pic x(14).
05 t01-de-char pic x(62).
05 t01-suspend pic x(01).
05 t01-filler pic x(30).

When I pre-compile a program that uses this definition using Oracle's
Pro*COBOL precompiler, I get this error:

Error at line 13, column 24 in file t01.read
select * into :t01-table-rec
........................1
PCB-S-00208, Incorrect type for host variable "T01-PRIME"

After some tests we have determined that the problem is that t01-prime
is a group name. If I take it out and promote the two fields below it
from level 10 to level 05, the program pre-compiles correctly. But I
cannot use this technique because it would mean a major revision of
almost one thousand programs, something we don't have the time for.
Therefore, my question is, is there a way to circumvent this problem?
Some precompilation switch that will make Microfocus Cobol accept the
group name?

I have already posted this same question to the MicroFocus development
forum and the answers that I got indicate that MF Cobol simply doesn't
allow that. Also, the procob manual states that

*************
Pro*COBOL allows the use of group items in embedded SQL statements.
Group items with elementary items (containing only one level) can be
used as host variables
*************

I'm trying posting here in this group as a last effort before dumping MF
Cobol... Can anyone think of a way for me to keep my definition as is
and still be able to pre-compile? Thanks in advance for any help.

Valdir Jorge

Chris

2004-05-13, 3:30 pm

Valdir Jorge <vjorge@vax2.concordia.ca> wrote in message news:<40A38884.9090401@vax2.concordia.ca>...
> Hi!
>
> We are doing a proof of concept project to see what are the issues when
> converting from VMS Cobol to Microfocus Cobol under Linux. One of the
> problems we're facing now is that Microfocus Cobol doesn't seem to like
> group names when defining a DB table. For example, we have a table
> called t01_table that is defined in VMS Cobol like this:
>
> 01 t01-table-rec.
> 05 t01-prime.
> 10 t01-tabno pic x(03).
> 10 t01-de-key pic x(14).
> 05 t01-de-char pic x(62).
> 05 t01-suspend pic x(01).
> 05 t01-filler pic x(30).
>
> When I pre-compile a program that uses this definition using Oracle's
> Pro*COBOL precompiler, I get this error:
>
> Error at line 13, column 24 in file t01.read
> select * into :t01-table-rec
> .......................1
> PCB-S-00208, Incorrect type for host variable "T01-PRIME"
>
> After some tests we have determined that the problem is that t01-prime
> is a group name. If I take it out and promote the two fields below it
> from level 10 to level 05, the program pre-compiles correctly. But I
> cannot use this technique because it would mean a major revision of
> almost one thousand programs, something we don't have the time for.
> Therefore, my question is, is there a way to circumvent this problem?
> Some precompilation switch that will make Microfocus Cobol accept the
> group name?
>
> I have already posted this same question to the MicroFocus development
> forum and the answers that I got indicate that MF Cobol simply doesn't
> allow that. Also, the procob manual states that
>
> *************
> Pro*COBOL allows the use of group items in embedded SQL statements.
> Group items with elementary items (containing only one level) can be
> used as host variables
> *************
>
> I'm trying posting here in this group as a last effort before dumping MF
> Cobol... Can anyone think of a way for me to keep my definition as is
> and still be able to pre-compile? Thanks in advance for any help.
>
> Valdir Jorge



Hi Valdir!

We had the same problem when migrating from C-ISAM files to an Oracle
database. Unfortunately I don't think you're going ot like this
answer:

Your group item, t01-table-rec, is not a group item composed of
elementray items because the t01-prime field is also a group item.
This violates the rule established in the Pro*COBOL manual.

Here is the only work-around which we found to be effective and of
minimal impact in terms of code changes:

01 t01-table-rec.
05 t01-prime pic x(17).
05 t01-prime-r redefines t01-prime.
10 t01-tabno pic x(03).
10 t01-de-key pic x(14).
05 t01-de-char pic x(62).
05 t01-suspend pic x(01).
05 t01-filler pic x(30).

Now you're group item only contains elementary items (since the
redefinition is "ignored" by Pro*COBOL). You should find that you're
code works as expected now. It's a bit of a pain, but if you've got
your table/record layouts isolated, it shouldn't be a major
undertaking to make this type of modification.

I was unable to find a switch (or other shortcut) to accomplish this,
so I'm going to follow this post eagerly to see if someone has learned
some new tricks.


Good luck!


Chris
Valdir Jorge

2004-05-13, 4:30 pm

Hi Chris!

You wrote:

> We had the same problem when migrating from C-ISAM files to an Oracle
> database. Unfortunately I don't think you're going ot like this
> answer:
>
> Your group item, t01-table-rec, is not a group item composed of
> elementray items because the t01-prime field is also a group item.
> This violates the rule established in the Pro*COBOL manual.
>
> Here is the only work-around which we found to be effective and of
> minimal impact in terms of code changes:
>
> 01 t01-table-rec.
> 05 t01-prime pic x(17).
> 05 t01-prime-r redefines t01-prime.
> 10 t01-tabno pic x(03).
> 10 t01-de-key pic x(14).
> 05 t01-de-char pic x(62).
> 05 t01-suspend pic x(01).
> 05 t01-filler pic x(30).
>
> Now you're group item only contains elementary items (since the
> redefinition is "ignored" by Pro*COBOL). You should find that you're
> code works as expected now. It's a bit of a pain, but if you've got
> your table/record layouts isolated, it shouldn't be a major
> undertaking to make this type of modification.


I tried your solution and now I'm getting this error message:

Error at line 13, column 24 in file t01.read
select * into :t01-table-rec
........................1
PCB-S-00208, Incorrect type for host variable "T01-PRIME-R"

So, now it is complaining about the new variable t01-prime-r!!

> I was unable to find a switch (or other shortcut) to accomplish this,
> so I'm going to follow this post eagerly to see if someone has learned
> some new tricks.


Me, too, I'll keep my hopes up...

Valdir Jorge

Lueko Willms

2004-05-13, 7:30 pm

Am 13.05.04
schrieb vjorge@vax2.concordia.ca (Valdir Jorge)
auf /COMP/LANG/COBOL
in 40A38884.9090401@vax2.concordia.ca
ueber MicroFocus Cobol: use of group names in DB definitions

VJ> 01 t01-table-rec.
VJ> 05 t01-prime.
VJ> 10 t01-tabno pic x(03).
VJ> 10 t01-de-key pic x(14).
VJ> 05 t01-de-char pic x(62).
VJ> 05 t01-suspend pic x(01).
VJ> 05 t01-filler pic x(30).
VJ>
VJ> When I pre-compile a program that uses this definition using Oracle's
VJ> Pro*COBOL precompiler, I get this error:
VJ>
VJ> Error at line 13, column 24 in file t01.read
VJ> select * into :t01-table-rec
VJ> .......................1
VJ> PCB-S-00208, Incorrect type for host variable "T01-PRIME"
VJ>
VJ> After some tests we have determined that the problem is that
VJ> t01-prime is a group name.

How about REDEFINing it?

Like this:


05 t01-prime.
05 filler redefines t01-prime.
10 t01-tabno pic x(03).
10 t01-de-key pic x(14).


Does that work?


Yours,
Lüko Willms http://www.mlwerke.de
/--------- L.WILLMS@jpberlin.de -- Alle Rechte vorbehalten --

"Die Arbeit in weißer Haut kann sich nicht dort emanzipieren, wo sie
in schwarzer Haut gebrandmarkt wird." - Karl Marx 12.11.1866
LX-i

2004-05-13, 10:30 pm

Valdir Jorge wrote:
> Hi!
>
> We are doing a proof of concept project to see what are the issues
> when converting from VMS Cobol to Microfocus Cobol under Linux. One of
> the problems we're facing now is that Microfocus Cobol doesn't seem to
> like group names when defining a DB table. For example, we have a table
> called t01_table that is defined in VMS Cobol like this:
>
> 01 t01-table-rec.
> 05 t01-prime.
> 10 t01-tabno pic x(03).
> 10 t01-de-key pic x(14).
> 05 t01-de-char pic x(62).
> 05 t01-suspend pic x(01).
> 05 t01-filler pic x(30).


how about...
01 t01-table-rec.
05 t01-tabno pic x(03).
05 t01-de-key pic x(14).
[snip]
66 t01-prime renames t01-tabno thru t01-de-key

That way, you've still got t01-prime named, it's still alphanumeric, and
pro*cobol shouldn't gripe because you're now selecting into elementary
items.

> *************
> Pro*COBOL allows the use of group items in embedded SQL statements.
> Group items with elementary items (containing only one level) can be
> used as host variables
> *************


There's where you're hitting your limitation. Since you're using the
01-level as a group-level item, you're only allowed one level below it
(in your example above, the 05-level). The 10-level exceeds this.

> I'm trying posting here in this group as a last effort before dumping MF
> Cobol... Can anyone think of a way for me to keep my definition as is
> and still be able to pre-compile? Thanks in advance for any help.


If the 66-levels work, they should drop right in with no code changes at
all. Of course, if you're doing something extraordinary with them,
there may be tweaks needed. Anyway, best of luck.


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~ / \ / ~ Live from Montgomery, AL! ~
~ / \/ o ~ ~
~ / /\ - | ~ LXi0007@Netscape.net ~
~ _____ / \ | ~ http://www.knology.net/~mopsmom/daniel ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ I do not read e-mail at the above address ~
~ Please see website if you wish to contact me privately ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~

Robert Wagner

2004-05-14, 10:30 pm

Valdir Jorge <vjorge@vax2.concordia.ca> wrote:

> Hi!
>
> We are doing a proof of concept project to see what are the issues when
>converting from VMS Cobol to Microfocus Cobol under Linux. One of the
>problems we're facing now is that Microfocus Cobol doesn't seem to like
>group names when defining a DB table. For example, we have a table
>called t01_table that is defined in VMS Cobol like this:
>
>01 t01-table-rec.
> 05 t01-prime.
> 10 t01-tabno pic x(03).
> 10 t01-de-key pic x(14).
> 05 t01-de-char pic x(62).
> 05 t01-suspend pic x(01).
> 05 t01-filler pic x(30).
>
>When I pre-compile a program that uses this definition using Oracle's
>Pro*COBOL precompiler, I get this error:
>
>Error at line 13, column 24 in file t01.read
>select * into :t01-table-rec


Your complaint is not against Micro Focus, it is against the Oracle
pre-compiler, which sucks. It is also against your own source code which never
should have said 'select *'. That's not database technlogy, that's VSAM
technology. That means every time the table definition is changed, the source
code must be changed.

Databases were supposed to get us away from that. In places I've worked as
contractor, they actually did. We could make changes to databases without
requiring recompilation of application programs.

My advice is rewrite the Select statements to specify the columns being read and
rewrite the Inserts to specify the columns inserted. That's how databases are
supposed to work.
>.......................1
>PCB-S-00208, Incorrect type for host variable "T01-PRIME"
>
>After some tests we have determined that the problem is that t01-prime
>is a group name. If I take it out and promote the two fields below it
>from level 10 to level 05, the program pre-compiles correctly. But I
>cannot use this technique because it would mean a major revision of
>almost one thousand programs, something we don't have the time for.
>Therefore, my question is, is there a way to circumvent this problem?
>Some precompilation switch that will make Microfocus Cobol accept the
>group name?
>
>I have already posted this same question to the MicroFocus development
>forum and the answers that I got indicate that MF Cobol simply doesn't
>allow that. Also, the procob manual states that
>
>*************
>Pro*COBOL allows the use of group items in embedded SQL statements.
>Group items with elementary items (containing only one level) can be
>used as host variables
>*************
>
>I'm trying posting here in this group as a last effort before dumping MF
>Cobol... Can anyone think of a way for me to keep my definition as is
>and still be able to pre-compile? Thanks in advance for any help.
>
>Valdir Jorge
>


Valdir Jorge

2004-05-17, 11:30 am

Hi LX-i!

You wrote:

> how about...
> 01 t01-table-rec.
> 05 t01-tabno pic x(03).
> 05 t01-de-key pic x(14).
> [snip]
> 66 t01-prime renames t01-tabno thru t01-de-key
>
> That way, you've still got t01-prime named, it's still alphanumeric, and
> pro*cobol shouldn't gripe because you're now selecting into elementary
> items. [...]


Great! It works!! It will still be quite a lot of conversion work but
it is much less than if I had to change my selects! Thank you very much!

Valdir Jorge

Valdir Jorge

2004-05-17, 11:30 am

Hi Robert!

You wrote:

> Your complaint is not against Micro Focus, it is against the Oracle pre-compiler, which sucks.


I agree... :-(

> It is also against your own source code which never should have said 'select *'.


I can't do much about that, it is a legacy system, it was designed more
than twenty years ago... If I could restart from scratch, I would do it
differently, of course, but total redesign is absolutely not an option
for me.

Valdir Jorge

Robert Wagner

2004-05-17, 5:30 pm

Valdir Jorge <vjorge@vax2.concordia.ca> wrote:


*'.
[color=darkred]
> I can't do much about that, it is a legacy system, it was designed more
>than twenty years ago... If I could restart from scratch, I would do it
>differently, of course, but total redesign is absolutely not an option
>for me.


I just converted an AS/400 system that used the same technique. Replacing * with
column names is mechanical and risk free. Future maintainers will thank you for
doing it right.

The AS/400 had the same limitation as Pro*Cobol -- goes down one level only.
They got around it this way:

01 t01-record.
05 t01-prime.
10 pic x(03).
10 pic x(14).
05 pic x(200).
01 t01-table-rec redefines t01-record.
05 t01-tabno pic x(03).
05 t01-de-key pic x(14).
05 t01-de-char pic x(62).
05 t01-suspend pic x(01).
05 t01-filler pic x(30).


LX-i

2004-05-17, 9:30 pm

Valdir Jorge wrote:

> Hi LX-i!
>
> You wrote:
>
>
>
> Great! It works!! It will still be quite a lot of conversion work
> but it is much less than if I had to change my selects! Thank you very
> much!


Glad it helped. :)


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~ / \ / ~ Live from Montgomery, AL! ~
~ / \/ o ~ ~
~ / /\ - | ~ LXi0007@Netscape.net ~
~ _____ / \ | ~ http://www.knology.net/~mopsmom/daniel ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ I do not read e-mail at the above address ~
~ Please see website if you wish to contact me privately ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com