Re: Using LIKE to define records in 4GL
Posted in 1996
>
> brent@hypercom.co.nz (Brent Jackson) nattered on and on about:
>
> >We have no problems using LIKE, but it is forbidden to use the "RECORD LIKE
> >table.*" and the "SELECT * FROM" constructs. It is the * that causes
> >problems, rather than the LIKE.
>
> I seem to have missed the original question. What problems are you
> specifically referring to here? The only problem I know of with using
> LIKE constructs is in INPUT ARRAY navigation. The user can get stuck
> on a line if the field they are currently in is a NOT NULL column in
> the database. We work around this by using formonly screen fields
> when necessary, althought this breaks the syscolval and syscolatt
> funtionality completely.
>
> Are there other difficulties I should be aware of? Fourgen uses this
> construct heavily in their program generator.
The biggest problem, with it is in a maintenance situation.
Here check it out.
CREATE table tab (
a char(1),
b char(1),
c char(1))
DEFINE abc RECORD LIKE tab.*
# So abc looks like:
abc.a, abc.b, abc.c
.....
SELECT * FROM tab INTO abc.*....
compile 4gl code....
ALTER TABLE tab ADD COLUMN d char(1) BEFORE column b
run 4gl code.... (compiled on old schema)
Your cursor is now doing:
SELECT a, d, b, c
INTO abc.a, abc.b, abc.c
If you have made a habit of this, that's a lot of places to track it down
and fix (at very least by recompiling).
If you did
DEFINE abc RECORD
a char(1),
b char(1),
c char(1)
AND your select statement did:
SELECT a, b, c FROM tab INTO abc.*
Then you are insulated - no matter what new columns are added your code will
still work the way it was intended.
So is it such a big sacrifice to have to type in the extra code? 1 minute
now will save you hours down the road.
cheers
j.
_____________________________________________________________________________
Jack Parker - Hewlett Packard, DMD/IS Boise, Idaho, USA
jparker@hpbs3645.boi.hp.com
_____________________________________________________________________________
"I'm with the IRS, I'm here to help you"
_____________________________________________________________________________
Any opinions expressed herein are my own and not those of my employers.
_____________________________________________________________________________