Re: 4GL - Database Names
Posted in 1996
In <52rsof$m5@nwnews.wa.com> bpd@criinc.com (Perry Dillard) writes: >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 Bloody good! Can you add this to the Informix Users group bag of tricks on their Web home page? This kind of ingenuity should be rewarded. Tell you what, I'll send in a dollar and add your name to one of those email chainletters. It could earn you $50000 you know :) Bryan Tonnet batonnet@zeta.org.au