Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2005

    Unanswered: 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.


    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

  2. #2
    Join Date
    Jun 2006


    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

Posting Permissions

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