Unanswered: putenv("DB2INSTANCE=db2inst1") problem
I'm trying to get database list for each instance locally in my c++ program. For each instance I do:
1. use putenv to set DB2INSTANCE environment variable
2. use sqleatin to attatch to the instance
3. use db2DbDirOpenScan,db2DbDirGetNextEntry and db2DbDirCloseScan to get database list
4. detach the instance
But this only works for the first instance, If I put db2inst1 in first loop, I always get database list for db2inst1 for all other instances. If I put db2inst2 in first loop, then I always get database list for db2inst2 for all other instances. Seems like set DB2INSTANCE only works the first time in the application, and was cached by the application somehow.
Used different context to control each instance, but didn't make a difference.
Can anybody help? I have been struggling with this problem for a long time and can't solve it.