Last active
April 24, 2019 15:53
-
-
Save jkyeung/842398142dfbdfa135c1ccabb77e37d7 to your computer and use it in GitHub Desktop.
Problem with iPgm parameters in python-itoolkit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itoolkit import iToolKit, iPgm, iData | |
try: | |
# The following uses pyodbc, which is the preferred way to connect | |
# from Windows or Linux. | |
import pyodbc | |
from itoolkit.odbc.iodbccall import iODBCCall as DatabaseTransport | |
except ModuleNotFoundError: | |
# The following uses ibm_db, which is the preferred way to connect | |
# from PASE. | |
pyodbc = None | |
from itoolkit.db2.idb2call import iDB2Call as DatabaseTransport | |
LIBRARY = 'MYLIB' # adjust this yourself | |
def new_transport(): | |
if pyodbc: | |
# Adjust these yourself as necessary. | |
return DatabaseTransport(pyodbc.connect( | |
driver='{iSeries Access ODBC Driver}', | |
system='1.2.3.4', | |
uid='username', | |
pwd='password')) | |
return DatabaseTransport() | |
def zero(trans): | |
print('zero...') | |
itool = iToolKit(irow=False) | |
itool.clear() | |
itool.add(iPgm('pgm', 'PARMCOUNT', {'lib': LIBRARY})) | |
print(itool.xml_in()) | |
itool.call(trans) | |
print(itool.dict_out('pgm')) | |
def one(trans): | |
print('one...') | |
itool = iToolKit(irow=False) | |
itool.clear() | |
itool.add(iPgm('pgm', 'PARMCOUNT', {'lib': LIBRARY}) | |
.addParm(iData('p1', '1a', ''))) | |
print(itool.xml_in()) | |
itool.call(trans) | |
print(itool.dict_out('pgm')) | |
def two(trans): | |
print('two...') | |
itool = iToolKit(irow=False) | |
itool.clear() | |
itool.add(iPgm('pgm', 'PARMCOUNT', {'lib': LIBRARY}) | |
.addParm(iData('p1', '1a', '')) | |
.addParm(iData('p2', '1a', ''))) | |
print(itool.xml_in()) | |
itool.call(trans) | |
print(itool.dict_out('pgm')) | |
zero(new_transport()) | |
two(new_transport()) | |
one(new_transport()) | |
zero(new_transport()) # zombie parameter? | |
zero(new_transport()) # zombie parameter still alive? | |
print('Done.') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*----------------------------------------------------------------* | |
D parms s 3 0 | |
*----------------------------------------------------------------* | |
C eval parms = %parms | |
C parms dsply | |
C return | |
*----------------------------------------------------------------* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment