Problem with SQLConnect

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
angelovaira
Participant
Posts: 16
Joined: Fri Mar 28, 2003 4:36 am
Location: Italy - Roma

Problem with SQLConnect

Post by angelovaira »

I am trying to execute a select statement from a datastage server routine.
It was ok and was working on datastage 7.5 but now, on 8.1 version it doesn't work.
The parameters that I pass to the SqlConnect function are correct, they work on 7.5 version.

Thanks a lot for help...

This is the code:

$INCLUDE UNIVERSE.INCLUDE ODBC.H

* Extract Argnuments from InputArg

RoutineName = 'ExecControl'

henv = SQL.NULL.HENV
hdbc = SQL.NULL.HDBC
hstmt = SQL.NULL.HSTMT

Ans = 0

Connected = @FALSE

* THIS IS OK
Res = SQLAllocEnv(henv)
if Res <> SQL.SUCCESS then
Message = "Error in henv":status
Call DSLogWarn(Message,RoutineName)
Ans = 90
End Else

* THIS IS OK
Res = SQLAllocConnect(henv,hdbc)
if Res <> SQL.SUCCESS then
Message = "Error in henv":status
Call DSLogWarn(Message,RoutineName)
Ans = 91
End Else

* THIS DOESN'T WORK, status <> SQL.SUCCESS
status = SQLConnect(hdbc,DNS_NAME,ODS_USER,ODS_PWD)
if status <> SQL.SUCCESS then
Message = "Error in henv":status
Call DSLogWarn(Message,RoutineName)
Ans = 92
End Else ....
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What is the status it actually returns?
-craig

"You can never have too many knives" -- Logan Nine Fingers
angelovaira
Participant
Posts: 16
Joined: Fri Mar 28, 2003 4:36 am
Location: Italy - Roma

Post by angelovaira »

chulett wrote:What is the status it actually returns? ...
The status is -1
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

That's just SQL.ERROR. You have to call SQLError() repeatedly to strip the error information off the handle, to learn precisely what went wrong.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
angelovaira
Participant
Posts: 16
Joined: Fri Mar 28, 2003 4:36 am
Location: Italy - Roma

Post by angelovaira »

ray.wurlod wrote:That's just SQL.ERROR. You have to call SQLError() repeatedly to strip the error information off the handle, to learn precisely what went wrong. ...
Please, can you tell me how to use the SQLError function ? Which are the parameters ?
Thanks
angelovaira
Participant
Posts: 16
Joined: Fri Mar 28, 2003 4:36 am
Location: Italy - Roma

Post by angelovaira »

ray.wurlod wrote:That's just SQL.ERROR. You have to call SQLError() repeatedly to strip the error information off the handle, to learn precisely what went wrong. ...
I did like this:

* THIS DOESN'T WORK, status <> SQL.SUCCESS
status = SQLConnect(hdbc,DNS_NAME,ODS_USER,ODS_PWD)
if status <> SQL.SUCCESS then
Ans = SQLError(hEnv,hConn,"SQLConnect(hConn,DNS_NAME,ODS_USER,ODS_PWD)",SQLstate,DBMSCode,ErrText) End Else ....

and the result of the SQLError function was -2, but I don't know wath does it mean.

Angelo
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

See your other post on SQLError().

In particular, the third argument thereof must be a statement handle.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply