Re: Accessing multiple databases from same process
Posted in 1997
Daniel Wright wrote: > > I thought I could accomplish this by setting environment variables > before opening the database. After wasting 15 minutes determining that > Informix failed to supply fgl_putenv() to accompany fgl_getenv(), I > resorted to ESQL/C. However when I tried on Informix 5.??, my first > putenv("TBCONFIG=tbconfig_prd") allowed me to access the production > database (even though I ran the program from development), but after I > closed the database, issued my 2nd putenv("TBCONFIG=tbconfig_dev"), and > then re-opened the database, I was still accessing production. I added You are doing this the hard way. I assume that you are referring to accessing databases residing in multiple instances, perhaps on the same machine perhaps on different machines. First why this does not work, then how to make it work, third a better way to do this: 1) When you CLOSE DATABASE the sqlturbo process does not exit so when you OPEN DATABASE after changing the environment the sqlturbo process which actually opens the database still has the old environment. 2) Call sqlexit(), which will shutdown the current sqlturbo process, after closing the database and the rest should work as expected. 3) It would be better to specify the servername as part of the database and access the database remotely if you will be switching databases frequently as this will not incurr the overhead of starting up a new sqlturbo for each new database/server combination. In ESQL 7.xx you can set up multiple connections for jobs like this and then just switch connections (SET CONNECTION TO ...) which is MUCH faster than either your method or mine for 5.0x code. Art S. Kagel