Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2008

    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.



  2. #2
    Join Date
    Oct 2008
    If I start separate process for each instance, then it works. But I want to do it in one process. Is it possible?

  3. #3
    Join Date
    Apr 2008
    try setenv and unsetenv functions.

    Also, can you explain your logic clearly? like how are you passing list of instances? Is it an array of strings? or is this code inside a function/SP and you are passing instance name as a parameter?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts