If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > putenv("DB2INSTANCE=db2inst1") problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-05-08, 10:27
mouse99 mouse99 is offline
Registered User
 
Join Date: Oct 2008
Posts: 8
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.

Thanks.

Jane
Reply With Quote
  #2 (permalink)  
Old 11-05-08, 14:23
mouse99 mouse99 is offline
Registered User
 
Join Date: Oct 2008
Posts: 8
If I start separate process for each instance, then it works. But I want to do it in one process. Is it possible?
Reply With Quote
  #3 (permalink)  
Old 11-06-08, 15:02
madhu_kaza madhu_kaza is offline
Registered User
 
Join Date: Apr 2008
Posts: 39
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?

Thanks,
Madhavi.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On