Re: DATABASE statement catch-22
Posted in 1994
Joe Hartley said: > I have a 4GL program (written under RDS 4GL 4.10) that has a set of defines > at the beginning using the LIKE keyword, immediately following the DATABASE > statement. > <stuff deleted>.. > I have a new requirement for this program that requires that this program be > useable under any of our databases, fubar_1 through fubar_5, all of which > have the same schema. > > Is there a way I can do this that I'm missing? I can't call ARG_VAL() before Joe, This is what I do: 1. Before globals section I define a database that is used to compile the program. I my case this is an empty database for source compiles. This takes care of all the defines which are LIKES. If a variable is defined as LIKE a char(4), once its compiled its a char(4) and if you change the table/field to a char(6) your program still has it as a char(4) until you recompile. 2. In my main, and as a menu function I have a function select_db() (select database). It goes into a while loop until the user selects a valid database or quites the program. The user enters a database name, the program does an database p_dbname, and if status = 0 everything is OK. (If you have a database open the Informix will close it when you open an new one). There are two functions for the database statement in 4GL programs. One is to tell the compiler where to/how to define variables. And two is to select a database to work with. The first database statement before the globals tells the compiler where to define stuff. The next database statement tells the program which one to use. And you can have many databases open - One at a time, and if they all use the same schema you should have no problem switching between them. Joe Hartley said: > If I define the variables as above, then in my MAIN function close the > database, call my sysinit() function which puts the current database name > in my dbname variable, and give the command DATABASE dbname, the program > drops the definition of om30cus, and I am unable to access it. I am not sure I understand what you mean here. If om30cus is the name of the database you compiled with ( database name before the globals ) that is not changed until you recompile with a new name. If you want two databases open at the same time the you need I-STAR and Online. Please let me know if you have more questions. Regards - lester ############################################################################# # Lester Knutsen lester@access.digex.net # # Advanced DataTools Corporation Voice: 703-256-0267 # # Control you Informix database security with DB Privileges # #############################################################################