Re: Is there a problem with RECORD LIKE notation
Posted in 1998
Brian,
I have to admit I can't see much reason in not using the LIKE notation
in 4gl programming. As to the ".*" notation, I think this is a matter of
taste and the particular environment. Using the ".*" notation is
obviously much quicker, more convenient and less prone to error upon
first coding at least. As you say, all you have to do is recompile when
table structures are modified.
This is fine if your programs are all in one place, controlled by a
tight group of programmers. A commonly used table may require
recompiling all 4gl modules, but that's not much of a drawback.
In a less organized environment where programs are being produced by
many groups of people that access the same tables, you can run into
problems with the ".*" notation. Note that if you avoid the ".*"
notation you don't have to recompile any programs that aren't directly
affected by a table alteration. For example, if a column is added to a
table then the only programs that may have to be recompiled are those
that have to insert values into the new column.
There's also a middle philosophy that says use the ".*" notation only in
those programs that maintain the given table. Programs that may be
considered extra like reports and other programs that reference the
table casually don't use the ".*". Most table alterations would then
only require recompilation of the most directly involved programs which
probably have to be modified anyway.
I also think the ".*" is best avoided in PC client/server tools (2 tier)
where different users may be using different versions of the application
simply because it's more cumbersome to update the application to all
users. One of the advantages of 4gl is that you recompile and presto all
the users will be using the new version and any users currently in the
old version are easily identified.
Always ready to argue the benefits of good old 4gl :)
Best wishes,
----------------------------------------------------------------------
John H. Frantz Power-4gl: Extending Informix-4gl
john@rl.is http://www.rl.is/~john/pow4gl.html
Brian McGinity wrote:
>
> I've been programming in 4gl for four years. I just finished my first
> consultant position and have started a new job in a new company.
>
> This company is against using RECORD LIKE declarations. I can't
> figure out why. Also they don't want to use .* notation.
>
> i.e.
>
> DEFINE w_record RECORD LIKE tbl.*
>
> SELECT * INTO w_record.*
> FROM tbl>
> They would rather see:
>
> DEFINE w_elm1 CHAR(2),
> w_elm2 INTEGER
>
> SELECT elm1, elm2 INTO w_elm1, w_elm2
> FROM tbl>
> I have no idea why. The record version is much better when a table is
> changed--just recompile and go. According to Informix, it better to
> select entire rows from tables. Plus it saves time and is less prone
> to error.
>
> Today I had wrote a fetch statement to select some rows out of a table
> that had over 50 elements. This is insane! Upper management is
> pushing for this project, and I'm stuck preparing fetch and insert
> statements.
>
> It's not in their standards. Am I missing something?
>
> Brian McGinity
>
>