ConnectToDB2 routine

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
abhilashnair
Participant
Posts: 284
Joined: Fri Oct 13, 2006 4:31 am

ConnectToDB2 routine

Post by abhilashnair »

i have written a routine to connect to db2

Equate RoutineName To "ConnectToDB2"
Equate DBNAME TO Arg1
Equate DBSCHEMA TO Arg2
DB2CntCmd = "db2 CONNECT TO ":DBNAME
ResultText = @Null

Call DSExecute("UNIX", DB2CntCmd, ResultText, SystemReturnCode)

If SystemReturnCode <> 0 Then
Ans = "1"
Return(Ans)
End

If SystemReturnCode = 0 Then
Ans = "0"
Return(Ans)
End

--------------------------------------------------------------------------------

The Ans=1
Please let me know why is the routine not connecting to DB2
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

Call DSLogWarn(ResultText, "Problem connecting")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

In other words, you need to have the routine tell you what went wrong. Plus... Where is DBSCHEMA being used? What user/password is it connecting as? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
abhilashnair
Participant
Posts: 284
Joined: Fri Oct 13, 2006 4:31 am

Post by abhilashnair »

Hi Craig
It would be very helpful if you could rewrite that routine for me
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'm sure it would. However, I don't know DB2 and don't have access to it in my environment. What did your DSLogInfo message show?
-craig

"You can never have too many knives" -- Logan Nine Fingers
abhilashnair
Participant
Posts: 284
Joined: Fri Oct 13, 2006 4:31 am

Post by abhilashnair »

I have modified the routine to
Equate RoutineName To "ConnectToDB2"
Equate DBNAME TO Arg1
DB2CntCmd = "db2 CONNECT TO ":DBNAME
ResultText = @Null

Call DSExecute("UNIX", DB2CntCmd, ResultText, SystemReturnCode)

If SystemReturnCode <> 0 Then
Ans = ResultText
Return(Ans)
End

If SystemReturnCode = 0 Then
Ans = "0"
Return(Ans)
End


This is returning the error as "Could not load the db2 program "
abhilashnair
Participant
Posts: 284
Joined: Fri Oct 13, 2006 4:31 am

Post by abhilashnair »

This is the complete error message

Result = Could not load program /db2t/gtstinsa/sqllib/bin/db2:
Could not load module /db2t/gtstinsa/sqllib/lib/libdb2.a(shr_64.o).
Dependent module /usr/opt/db2_08_01/lib/libdb2trcapi.a(shr_64.o) could not be loaded.
Member shr_64.o is not found in archive
Could not load module db2.
Dependent module /db2t/gtstinsa/sqllib/lib/libdb2.a(shr_64.o) could not be loaded.
Could not load module .
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Make sure the 32-bit libraries appear ahead of the 64-bit libraries in your shared library search path.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

...which was advised in the very first place. And if you do that, then even your DB2 stage will work. No need for a routine.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It has been repeatedly advised. :?
-craig

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