tags:

views:

583

answers:

2

Is it possible to successfully author a C / C++ program in *IX operating systems that operates on both 32-bit and 64-bit DB2 implementations simultaneously?

The exact requirement is to read from a 32-bit DB2 database and write into a 64-bit DB2 database.

A: 

I guess your problem is, that you have to load both libraries simultaneously. You can't just link both in the executable using two -l options, because the symbol names collide. If this is the problem, dlopen if your friend.

#include <dlfcn.h>

void * handle=dlopen(filename,RTLD_NOW|RTLD_GLOBAL);

bool (*some_function)(char * name);
some_function=(bool (*)(char *))dlsym(handle,"name_of_some_function");
if (some_function("test")) {
    ....
} else {
    ....
}

Because I don't know DB2 I can't help you any further, but if this was the problem, you should now have everything to solve the problem.

bothie
+3  A: 

Since the C Common Client uses a network connection, there's no obvious reason why the 32-bit client should not connect to either a 32-bit or a 64-bit server (or both on separate connections). The same comment applies to 64-bit clients. The DRDA protocol used to communicate between client and server should be OK.

I can answer definitively for Informix (which you didn't ask about) - I use 32-bit or 64-bit ESQL/C to connect to either 32-bit or 64-bit IDS servers without problem. The only limitation is on a shared memory connection; then the client and server must be of the same 'bittiness'. But the network connections and the local (stream, socket) connections are neutral.

Jonathan Leffler
Sometimes I wish I could accept answers to questions that aren't mine. This would get one such check-mark. The same answer applies to DB2.
Tanktalus
@Tanktalus: thanks for confirmation that my answer applies to DB2 too.
Jonathan Leffler