|
If the record size changed, then you'll get an error when reading -- and
therefore will be in the same exact situation you were with
LVLCHK(*YES)... no benefit from using your technique in that case.
But there are cases where there's additional functionality available
when RPG knows about each key in a composite keylist separately gfrom
the others. For example, you can READE on a partial key with an
externally-defined F-spec, just by specifying the first key in the
keylist. You can't do that in a program described scenario, you always
have to specify the entire keylist. Also, what happens if a key is
defined where part of the key is ASCEND and part is DESCEND? Or
something like absolute value on a key?
Scott Klement
hi Nathan,
The difference between using SQL with a program-defined data structure
and your suggestion of using an externally-defined DS with a
program-described read is rather important, I think.
With SQL, it reads the data one field at a time, and copies it to the
RPG field. IF the database definition is changed, an attempt is made to
convert the field from the database style to the program's definition.
For example, if the field has been enlarged from 9 digits to 11 digits,
the SQL would do the equivalent of an "eval", converting the field to
the 9-digit size because that's what the program has.
If the SQL technique uses an ext-def DS, then when the program is
recompiled, it'll automatically adjust the field to the new size. But
in the mean-time it did the best it could -- it converted the field back
to the original size on-the-fly
Compare that to your program-described READ technique with the ext-def
DS. In your case, if the field size changed from 9 to 11, it won't be
detected (unless the total record size has also changed, in which case
you'll get an error.) So if the field size got larger, but the record
size is the same (due to changes in other fields) your technique will
result in part of the DB field being loaded in to one program variable,
and another part being loaded into an unrelated variable. Try it!
If the record size changed, then you'll get an error when reading -- and
therefore will be in the same exact situation you were with
LVLCHK(*YES)... no benefit from using your technique in that case.
And the difference between using a DS for a keylist and using an actual
keylist is that RPG knows it's a keylist. In your case with the DS, the
raw bytes of the combined fields are used as a key... which works in
most cases, I guess.
But there are cases where there's additional functionality available
when RPG knows about each key in a composite keylist separately gfrom
the others. For example, you can READE on a partial key with an
externally-defined F-spec, just by specifying the first key in the
keylist. You can't do that in a program described scenario, you always
have to specify the entire keylist. Also, what happens if a key is
defined where part of the key is ASCEND and part is DESCEND? Or
something like absolute value on a key?
Plus, if your goal is simply to turn off level checking... why not just
specify LVLCHK(*NO)? Wouldn't that make it easier for the next guy to
see what you're up to?
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.