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 > accessing two database in db2 using C

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-11-06, 06:31
dlare9 dlare9 is offline
Registered User
 
Join Date: Aug 2005
Posts: 3
accessing two database in db2 using C

Hi to all,

I've created a C application that does DB2 access.
At first both are precompiling and binding work fine.
I was able to insert and retreive data from the database.

However, when I tried to add another process the output is not what I expected. Basically the process mentioned here is a conditional statement, saying that if a certain condition is not met, then the application would connect to another database.
When I first ran the application (expecting that it will connect to the "other" database I've created in DB2) I was able to connect successfully to the "other" database (through logging function that I've added). But when I try to Insert (and even run Select querry) a data to the "other" database I got a -805 error:
package not found in the database.


After googling I've found an answer (check the
command reference for a description of the 'PRECOMPILE PROGRAM' (='PREP') command)
. And that got me thinking about the .bat file I'm using to precompile and bind my Embeded SQL code (in C). I've made some modification to the .bat file (w/c basically calls the embprep.bat ) ,namely the name of the database.

Then ran the application again (expecting that it will connect to the "other" database I've created in DB2) and this time I was able to Insert and retrieve data from the "other" database.

Is there a way to access two database in db2 at the same time (in C)?
I've tried to google and also search this forum about this problem, but I found no meaningful answer (or maybe I'm using the wrong search keys..)

any help would be much appreciated.

Regards,
Jaro



***note***
I'm using MVC6 and my OS is win2k.
My database is : DB2 Universal Database Personal Edition , Version 8.1

As you can tell by my post, I'm still learning about making application that access db2. Most of the code that I've made were sample from the web , only edited some parts to my liking
Reply With Quote
  #2 (permalink)  
Old 07-11-06, 07:05
guyprzytula guyprzytula is offline
Registered User
 
Join Date: Jun 2006
Posts: 471
database

if you access different db in the same program - you have to bind the files to each db (-805 package not found)
I presume the access is in different luw (unit of work)
otherwise, you should create a nickname locally for the second db and so you can access both tables from different db in sam uow
__________________
Best Regards, Guy Przytula
DB2 UDB LUW certified V6/7/8
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