Question

In our Batch project we run a shell script,which in turn invokes a web service.Our requirement is to run a select query on a DB 2 Database and fetch say 1000 A_TYPE accounts,then we will have to use these accounts to get a list of other accounts(A_TYPE,B_TYPE collumns) by using A_TYPE accounts in a prepared statement from a ORACLE DB.

The problem is that for every 1000 A_TYPE accounts i have to prepare the statement 1000 times and execute it 1000 times to get the B_TYPE accounts.It is time taking and not so efficient.

So if someone could suggest me a way to pass a list or array of A_TYPE accounts and then get a list or hashmap of A_TYPE,B_TYPE accounts so that i can use them further,it would be very helpful. Also i have to update my Db2 DB with the B_TYPE accounts in the place of A_TYPE accounts. All my logic is written in web service operation(JAVA) itself.

UPDATE:

Yes i am directly accessing the DBs through JNDI names.In webservice handler logic i ll make a call to both the DB's.I donot know the DB2 version used since i access it using JNDI name,Oracle is 10 g.i have queries like

SELECT A_TYPE account from ADB2 TABLE based on  conditions (?,?) FETCH 1000 records  only"` and `SELECT A_TYPE_Account,B_TYPE_Account from ORACLE_TABLE where A_TYPE_Account='?(A_TYPE)'

No i dont have to worry about transactions.i dont have idea of host variables and DB2 Dynamic query.

No correct solution

OTHER TIPS

Assuming you do this Oracle <--> DB2 stuff a lot, consider getting
- Oracle Transparent Gateway for DRDA http://www.oracle.com/technetwork/database/gateways/index.html
- IBM Infosphere Federation Server
http://www-03.ibm.com/software/products/en/ibminfofedeserv/

Note if you have DB2 Advanced Enterprise Server Edition (AESE), Infosphere Federation Server is included.

Both products would allow you to use a single join query sent to one DB that returns data from both DBs. The Oracle product is really nice in that it allows Oracle to see the DB2 database as another Oracle DB and for DB2 to see the Oracle database as another DB2 database. (Thanks to IBM publishing the specs for both the client and server side of the DRDA protocol DB2 uses. Too bad no other vendor is willing to do so, though they have no trouble taking advantage of the fact IBM did so.)

Neither product is what I would call cheap.
For cheap, you could take advantage of Oracle Database Gateway for ODBC
http://docs.oracle.com/cd/E16655_01/gateways.121/e17936/toc.htm

If you really want to continue down the path you've started to...I see two options
1) have your java app batch insert the 1000 DB2 records into a temporary table in Oracle then use it in a join for the final results.
bulk insert from Java into Oracle
2) pass the 1000 TYPEA records as a single string parameter into a stored procedure on Oracle that parses them out and makes use of them (assuming they aren't too big)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top