Using ODBC to call stored procedures (Client Access)

Aaron Fransen aaronf at telusNOSPAMplanet.net
Tue Sep 11 20:30:24 EDT 2001


I brought this problem up a few months ago, but never quite found a
solution, and in the digging I've done since I've found some more
information but I'm hoping someone has some ideas.

I have a Python 2.1 app that makes extensive use of the Client Access
(win32) ODBC driver to connect to an AS/400 mini (several in fact). It works
flawlessly for doing SQL statements (Select, Insert, Delete etc.).

However, when I need to call a program and return a parameter, it doesn't
work so well. Calling the program is fine, but getting the parameter back is
a bit of an issue.

Let's say I have:
{Call MYLIB.MYPROG(?,?,?,?)}
as a parameter query in the original VB code the program is derived from.
The first two ? are input parameters, the second two are output.

In the first attempt, I tried to use both the native ODBC and mxODBC to run
the program. I can't seem to make either one understand the parameters.
Passing values instead of parameters runs the program just fine, but doesn't
return any of the values I need.

Then I tried using the hooks into the ActiveX API that exist in
ActivePython. At this point the Python code for running the parameterized
query is almost identical to the original VB code (with the obvious
syntactic differences). Going this way the query always returns "MYPROG in
libary MYLIB type *N not found". Digging into this, Client Access is
actually trying to say that one of the parameters is the wrong format.

Now one of the bugs with running ODBC parameters through OS/400 v4r3 is
(apparently) that ALL values passed to a CL program via ODBC take a string
attribute; if they need to be numeric, the CL must convert them (easy
enough).

As I said, the virtually identical code works in VB, and all other ODBC
functions work in the Python app, so I'm pretty sure it's not a
security/library list/etc problem.

Any ideas anyone?

Aaron Fransen
The GoMail Guy
http://gomail.dynu.com






More information about the Python-list mailing list