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 > query table in different database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-08-07, 07:36
nick.ncs nick.ncs is offline
Registered User
 
Join Date: May 2007
Location: somewhere in dbforums
Posts: 221
query table in different database

suppose i have databases DB1 and DB2 on the same server. Now i connect to DB2 using db2connect. Now how can i query tables of DB1????.
Reply With Quote
  #2 (permalink)  
Old 05-08-07, 07:42
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You can either use a distributed transaction, for example via XA, or you use DB2's federated capabalities.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 05-08-07, 07:54
nick.ncs nick.ncs is offline
Registered User
 
Join Date: May 2007
Location: somewhere in dbforums
Posts: 221
well can you give me an example using distributed transactions..........i mean like just a small piece of code.....or can u just redirect me to some place where it is available...i mean code....also i am writing a stored procedure which spans two databases on the same server....and i have to manipulate with the data present in these tables....

Last edited by nick.ncs; 05-08-07 at 08:01.
Reply With Quote
  #4 (permalink)  
Old 05-08-07, 11:09
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
I believe that type 2 connections are extensively documented in the DB2 manuals. I don't know which additional information you may need for those. Also, we have no idea about your application and programming language.

If you are inside a stored procedure, your only option in federation. Federation already comes with the necessary infrastructure for distributed transactions, i.e. it performs two-phase commit itself and DB2 acts as a transaction manager in that case.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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