Re: 4GL - Database Names
Posted in 1996
Topics: Stored Procedures & SPL, Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL
Forget the other posts and use the following ideaa. If you have an initialization routine that is called first thing in all your programs you can put the following code there. Otherwise you will need to add an initialization call as the first statement in main for all programs. This is generally a good technique and can also help you provide restart capability to your programs. ie. let users switch databases on the fly, which is actually a little trickier than it sounds. Anyway, here is the code: function init() define sqlStr char(80), nArgs smallint, idx smallint let sqlStr = null let nArgs = num_args() for idx = 1 to nArgs if arg_val(idx) = "-d" then let sqlStr = "database ", arg_val(idx+1) end if end for if sqlStr is not null then close database prepare openStmt from sqlStr execute openStmt # Check for errors and exit the program if there are any if sqlca.sqlcode != 0 then display "Error opening the database!" exit program(1) end if end if end function That should be it. Of course you'll have to recompile but this is a nice little technique to add to your programs. And the best part is that if you put it in a library, you can add it to programs as needed. You can always make a one time pass and add it to all programs as well. Hope This Helps, Perry Dillard CRI, Inc. bpd@criinc.com Edward Bidinotto <bidinott@ucar.edu> wrote: >I am working in an environment where the programmers have hard-coded the >database name in their 4GL code. >We are running Informix 5.0 and I wanted to know how can I pass in a >different database name on the fly to override the hard-coded one that >currently exists in all their programs. >I'm sure there is a variable that can be read in or passed in to say >what database name I want. >The only other option is for the programmers to take this hard-coded >database name out of their 300+ programs. >Any suggestions would be appreciated. >Tks >Ed >-- >---------------------------------------------------------------------------- >Ed Bidinotto bidinott@ucar.edu