Two Source or not Two Source
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Third-Party Tools & Monitoring
We use Informix 4GL to supplement a third-party accounting system. We have a test database and a production database. The structure of the databases, depending on third-party updates, may be different. I have a request to make our 4GL programs work with both databases. The simple answer is two sets of source code. I'd like to avoid this for a several reasons. Has anyone developed a solution for this conundrum?
Are both databases on the same physical system? sopicki wrote: > > We use Informix 4GL to supplement a third-party accounting system. We have > a test database and a production database. The structure of the databases, > depending on third-party updates, may be different. I have a request to > make our 4GL programs work with both databases. The simple answer is two > sets of source code. Id like to avoid this for a several reasons. Has > anyone developed a solution for this conundrum?
sopicki wrote: > > We use Informix 4GL to supplement a third-party accounting system. We have > a test database and a production database. The structure of the databases, > depending on third-party updates, may be different. I have a request to > make our 4GL programs work with both databases. The simple answer is two > sets of source code. Id like to avoid this for a several reasons. Has > anyone developed a solution for this conundrum? If both databases are different names on the same instance just have the databasename passed in on the commandline or via environment variable. Then in the program retrieve the databasename option or the environment var value (LET dbname = getarg( 1 ) -or- LET dbname = fgl_getenv( "DBNAME" )) then just change or add a database statement in the main program body (the one at the top will be used for compile time definitions only then) using the dbname variable. If the database names are the same but they live on different servers or instances than life is even easier! Make sure you do not have a servername included with the databasename in the DATABASE statement and just change the INFORMIXSERVER environment variable from the development servername to the production servername and voila! Art S. Kagel
In article <36E5A924.56FA@bloomberg.net>, Art S. Kagel <kagel@bloomberg.net> writes >sopicki wrote: >> >> We use Informix 4GL to supplement a third-party accounting system. We have >> a test database and a production database. The structure of the databases, >> depending on third-party updates, may be different. I have a request to >> make our 4GL programs work with both databases. The simple answer is two >> sets of source code. Id like to avoid this for a several reasons. Has >> anyone developed a solution for this conundrum? > >If both databases are different names on the same instance just have >the databasename passed in on the commandline or via environment >variable. Then in the program retrieve the databasename option or the >environment var value (LET dbname = getarg( 1 ) -or- LET dbname = >fgl_getenv( "DBNAME" )) then just change or add a database statement >in the main program body (the one at the top will be used for compile >time definitions only then) using the dbname variable. > i.e. have a main module (shared by all programs which does:- MAIN DEFINE dbname CHAR(50) LET dbname = fgl_getenv("DBNAME") IF ((LENGTH(dbname CLIPPED)) = 0) THEN ERROR "unknown database name" END PROGRAM END IF DATABASE dbname CALL FN_main() END MAIN Each program implements an FN_main() function which does that actual work. >If the database names are the same but they live on different servers >or instances than life is even easier! Make sure you do not have a >servername included with the databasename in the DATABASE statement and >just change the INFORMIXSERVER environment variable from the >development servername to the production servername and voila! > >Art S. Kagel -- David Williams