4GL-Scripts for more than one database
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Hello, I'm using different 4gl-scripts which are started in a shellscript (./<name>.4ge). In the first line of the 4gl-script I reference to the database . Now, I need these 4gl-scripts also for another database. They will be started from a different shellscript. I don't like to duplicate these 4gl-scripts. So, my question is: How can I use only one 4gl-script for two databases. Is there a possibility to deliver the database reference as a variable in the shell-script? Could anybody help me? Thank you in advance, Gerhard P.S.: I'm working on a UNIX machine.
Gerhard Schmidt wrote:
>
> Hello,
>
> I'm using different 4gl-scripts which are started in a shellscript
> (./<name>.4ge). In the first line of the 4gl-script I reference to the
> database .
> Now, I need these 4gl-scripts also for another database. They will be
> started from a different shellscript.
> I don't like to duplicate these 4gl-scripts.
>
> So, my question is:
>
> How can I use only one 4gl-script for two databases. Is there a possibility
> to deliver the database reference as a variable in the shell-script?
>
> Could anybody help me?
>
> Thank you in advance,
>
> Gerhard
>
> P.S.: I'm working on a UNIX machine.
How about this --- run in the shell script as follows:
program_name.4ge database_name
main
define dbname char(18)
let dbname = arg_val(1)
database dbname
select count(*) from systables
end main
Gerhard Schmidt wrote: > > Hello, > > I'm using different 4gl-scripts which are started in a shellscript > (./<name>.4ge). In the first line of the 4gl-script I reference to the > database . > Now, I need these 4gl-scripts also for another database. They will be > started from a different shellscript. > I don't like to duplicate these 4gl-scripts. > > So, my question is: > > How can I use only one 4gl-script for two databases. Is there a possibility > to deliver the database reference as a variable in the shell-script? > > Could anybody help me? A word of explanation. Joanne's reply is right on but terse. The DATABASE statement at the beginning of a 4GL program is needed only at compile time to evaluate any LIKE table... expression in declarations. If you do not have an executable DATABASE statement within your MAIN then the 4GL compiler copies the one from the top into MAIN for you. So all you have to do is have a DATABASE statement in MAIN which uses a variable containing the actual runtime database you want. You could use an environment variable or command line option to set its value as Joanne Dority suggests. Art S. Kagel