Re: Using LIKE to define records in 4GL
Posted in 1995
Of course you shouldn't use LIKE. The problem is exactly what to do instead. We have many old programs I wrote a long time ago when I didn't relize all the problems, and that shall be changed as they are updated for other reasons. To write out every record definition explisitly wherever it is needed and keeping selects in sync is a real pain. Particularly as we have hundreds of programs and over 100 tables. We are experimenting with include files (using the c-compilers include). We plan to use one include file for each record definition we need, and corresponding include files for the select, insert and possibly update for this record. If anyone has done this any comments and suggestions would be appreciated. Nils.Myklebust@ccmail.telemax.no NM-data, Dalsbergstien 7, N-0170 Oslo, Norway My opinions are those of my company } Mark.Denham@bbc.co.uk (Mark Denham) writes: } } Ok all, } } I feel like an argument. Has anyone got any views on the use of LIKE to } define } RECORDS in 4GL, or any limitations on how you use it based on personal } experience? } } To start the ball rolling I hate it and where I can insist that it is not } used. I particularly } dislike its use in GLOBALS files! } } Here are my reasons: } } 1) When used in the globals file, it results in the runtime app opening the } db and } attempting to locate the tables of interest. In an enviroment where you have } multiple } copies of the db, not necessarily with the same name, this method forces you } to have } to recompile the programs for each db, or to have a dummy db that is used to } compile and is left in existance in each db enviroment. } } 2) The db table and record become tightly coupled. Using LIKE tends to lead } to the } widespread use of select *, input by name record.*, display by name and so } forth. } These statements become very dependant on the layout of the table, and in an } evolving db environment, become a pain to maintain because you end up having } to test entire programs completely to check the affedt of inserting a column } instead of } only the sections of programs that use it. } } I prefer to define the record structures explicitly, and use LIKE (if at } all) to define } individual fields. I don't use it at all in a globals file and certainly not } in an environment } where there are multiple copies of the database with different names. } } Heres looking forward to an interesting debate. } }>>>