Passing Variables from UNIX to I4GL
Posted in 2000
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Could someone with I4GL experiance please help with the following problem:
1. same data base (different data) on 4 different servers scattered around
the country.
2. not enough money or trained people to manage all four sites (same old
story)
What I want to do is consolidate the four databases into the one Informix
Instance, but still keep the seperate databases (until the data can be
migrated into the same database). My plan of attack was to modify the 4gl
source code so that I could replace all the "database dbname;" statments
with a "database UNIX_ENVIROMENT_VARIABLE;" statement that way when the user
logs in the UNIX_ENVIROMENT_VARIABLE can be set in their .profile and it
will point them at the right database. therefor enabiling me to consolidate
on to the one instance.
UNIX=AIX, SHELL=ksh
INFORMIX=7.31UC5RDS = 7.2?
Adam Birch
AMBirch@hotmail.com
Hi Adam, > [...] My plan of attack was to modify the 4gl > source code so that I could replace all the "database dbname;" statments > with a "database UNIX_ENVIROMENT_VARIABLE;" statement that way when the user > logs in the UNIX_ENVIROMENT_VARIABLE can be set in their .profile and it > will point them at the right database. therefor enabiling me to consolidate > on to the one instance. You could go this way: Put a minimal "main" into a separate file with no SQL statements and no DEFINE...LIKE in it and call a function in an other file which replaces the former main. By not using DATABASE before or in the "main" Block your avoid an implicit generated DATABASE statement executed at the beginning of "main". In every 4GL-File which has no "main" in it you can safely use a DATABASE statement to define a compile time db without any need for this db to be there at run time. Your only have to ensure that the compile time database is identical to the later used run time db as far as DEFINE...LIKE is concerned. In your fake main function you can safely use something like: define db char(20) let db = fgl_getenv ("DBNAME") database db to connect to the actually needed db. Hope this helps. Paul
Hello Adam.
Alternatives
a)
1.- You can define a environment
variable "DATABASE=name_database;export DATABASE"
2.- Define a function in 4gl module "FUNCTION select_database()", In
this function you can extract database name with
sentence "database=FGL_GETVAL("DATABASE")" for include in prepare and
execute sentences.
b)1.- You can define a table with the names of the databases
2.- In the start of the program select the database
3.- Define a function in 4gl module "FUNCTON select_database
(db_selected)", you must include the database selected (db_selected) in
prepare and execute sentences.
ATTENTION:for alternatives a) and b) if you use sentence "DATABASE .."
in the start of each module before define globals variables. YOU NEED
call "FUNCTION select_database" in the START PROGRAM ONLY and the new
database was select for all modules.
Regards
Ruben
In article <uXIZ5.157978$e5.114629@newsfeeds.bigpond.com>,
"Adam" <AMBirch@hotmail.com> wrote:
> Could someone with I4GL experiance please help with the following
problem:
>
> 1. same data base (different data) on 4 different servers scattered
around
> the country.
> 2. not enough money or trained people to manage all four sites (same
old
> story)
>
> What I want to do is consolidate the four databases into the one
Informix
> Instance, but still keep the seperate databases (until the data can be
> migrated into the same database). My plan of attack was to modify the
4gl
> source code so that I could replace all the "database dbname;"
statments
> with a "database UNIX_ENVIROMENT_VARIABLE;" statement that way when
the user
> logs in the UNIX_ENVIROMENT_VARIABLE can be set in their .profile and
it
> will point them at the right database. therefor enabiling me to
consolidate
> on to the one instance.
>
> UNIX=AIX, SHELL=ksh
> INFORMIX=7.31UC5> RDS = 7.2?
>
> Adam Birch
> AMBirch@hotmail.com
>
>
Sent via Deja.com
http://www.deja.com/