Re: passing database through ARG_VAL?
Posted in 1998
Sean Kelsey wrote: > Start your 4gl app with > > DATABASE <tempdatabase> > ... > ... > LET db_name = arg_val(1) > DATABASE db_name > > Obviously, when the 4GL compiles, it must have all the necessary > tables within the tempdatabase so that it won't produce any errors. > Once the program has compiled, you can execure it passing it the > relevant database name. As long as its in the DBPATH (for SE) then > this should work okay. > > We have used the same thing using ODS 7.2x compiling against one > database and running it against another - it works fine !!! I am probably being unduly pedantic if I point out that you only need the non-proceduralDATABASE <tempdatabase> statement at the top of the file if you define variables LIKE table elements, or records LIKE tables. In general, and IMNSHO, if you are playing with multi-database systems, then the MAIN should be in a source file which contains no LIKE variable, so there is no need for the non-procedural database, which in turn means there's no need for the <tempdatabase> to exist at runtime because MAIN will not connect to any database by default unless it is compiled with a non-procedural database statement. This also speeds up the program startup because it avoids connecting to two databases before it really gets going, and connecting to a database is a relatively slow operation. In fact, with just a small modicum of care, you can write a generic MAIN program for your project and use it for all your programs: MAIN DEFER INTERRUPT DEFER QUIT CALL select_database() CALL real_main() END MAIN There are numerous minor variations on this theme; the key point is that apart from the DEFER operations (which must appear in MAIN), you simply compile this 6-line file, and each actual program starts with a function real_main() which contains the real program. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN #include <disclaimer.h>