Re: Accessing multiple databases from same process
Posted in 1997
Thanks for the very good explanation... I was trying to do this from home without any manuals and now that you jar my memory, I think I used separate processes a couple of years ago, because I realized sqlturbo was not restarted. [I'm very glad to hear about sqlexit()]. I've been spoiled enough w/ v7.xx for the past year or so, that I completely forgot about the spawned sqlturbo process. Your mentioning SET CONNECTION TO... reminds me that I need to continually read and re-read the manuals...After all, this is how I learned Informix in the first place, and since I usually have no use for them nowadays, they basically just look good on my bookshelf. Thanks again for your help, Art S. Kagel wrote: > 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 -- - Danny Wright danwright@bigfoot.com #include <stddisclaimers.h> Idiot, n.: A member of a large and powerful tribe whose influence in human affairs has always been dominant and controlling. - Ambrose Bierce, "The Devil's Dictionary"