Connect to multiple db2 databases

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
k1980pc
Participant
Posts: 9
Joined: Fri Jun 15, 2007 3:31 am

Connect to multiple db2 databases

Post by k1980pc »

Hi,
I have a db2 instance DATASERV with two databases DBMAIN and DBHAWK.
I am using db2/udb api to connect to DATASERV with user id(DSTAGE) and password.

The generated query is SELECT STAGEPARAM FROM DSTAGE.PARAM WHERE....

My concern is that both DBMAIN and DBHAWK has PARAM table, so how do I define which database the select should be done on.
RELAXEN UND WATSCHEN DER BLINKENLICHTEN
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sorry, don't know DB2 but if 'database' in this context is anything like an Oracle 'schema' then you just preface the table name with the database name. So, perhaps something like?

Code: Select all

SELECT STAGEPARAM FROM DSTAGE.DBMAIN.PARAM WHERE.... 
:?
-craig

"You can never have too many knives" -- Logan Nine Fingers
k1980pc
Participant
Posts: 9
Joined: Fri Jun 15, 2007 3:31 am

Post by k1980pc »

Hi Craig,
Thanks for the input. That worked on the older db (DBMAIN), but failed for the newer one.
Seems I need to run a CATALOG command which will make the ds server "aware" of the new remote database. Quite like creating aliases.

PS : They are quite different from oracle schema. Different databases running under a single server instance. Can be independently brought up/shut down etc. There are schemas under them... So I can address them as DBNAME.SCHEMANAME.TABLENAME.COLUMNNAME... phew... :)
RELAXEN UND WATSCHEN DER BLINKENLICHTEN
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ah... thanks for the explanation. If you've worked out the resolution, then please mark the post as Resolved. :D
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply