4GL: when to use the DATABASE statement
Posted in 1995
> Subject: Re: Setting database at runtime with 4GL > From: kerry@kcbbs.gen.nz (Kerry Sainsbury) > Date: Tue, 24 Jan 1995 19:37:13 +1200 > Reply-To: kerry@kcbbs.gen.nz (Kerry Sainsbury) > Organization: Kappa Crucis Unix BBS, Auckland, New Zealand > > In article <3g0pr8$an9@cssun.mathcs.emory.edu>, > alan@po.den.mmc.com (Alan Popiel) wrote: > > > Now the advice: > > You only need the declarative DATABASE statement in your 4GL source if you > > use the syntax "DEFINE program_something LIKE db_something". ... <snip> > > ... In general, I recommend against using the declarative form. > > *Why* do you recommend against DEFINEing LIKE database items? > > I've found it to be utterly invaluable when a new client decides they > need to (say) hold quantities to 3 decimal places, or support 20 character > product codes, or whatever other requirement they have. > [snip] > > Regards, > Kerry S My advice was sufficiently unclear that Kerry misunderstood it. I highly respect Kerry's opinions, so if he misunderstood me I presume that others did as well. Therefore I will restate my advice to make it clearer. I recommend against using the declarative DATABASE statement, *unless* you need it for DEFINE ... LIKE ... statements. Kerry is absolutely correct that using DEFINE ... LIKE ... makes your code easier to maintain, because it reduces the number of redundant declarations that must be synchronized. Using the DEFINE ... LIKE ... syntax *requires* the module to contain a declarative DATABASE statement. However, having the DATABASE statement in a 4GL code module makes that module dependent on the named database. If the module is a utility of some kind, you would normally want it to be as database-independent as possible, in order to make code-reuse easier. Thus, if the 4GL does *not* use DEFINE ... LIKE ... then I strongly suggest that it should *not* contain the declarative DATABASE statement. Regards, Alan ___________________________ ______________________| R. Alan Popiel |__________________________ \\ Internet: | Martin Marietta, SLS | / \\ alan@den.mmc.com | P.O. Box 179, M/S 3810 | Std disclaimers apply. / )Voice: | Denver, CO 80201-0179 USA | ( / 303-977-9998 |___________________________| (But you knew that!) \\ /________________________) (____________________________\\