getting results from IBM DB2 stored procedure #1384
Unanswered
DeltaFox0018
asked this question in
Q&A
Replies: 4 comments 2 replies
-
You might try this: cursor.execute(sql)
try:
rows = cursor.fetchall()
except pyodbc.ProgrammingError:
cursor.nextset()
rows = cursor.fetchall()
print(rows) |
Beta Was this translation helpful? Give feedback.
0 replies
-
I have tried but the error is the same |
Beta Was this translation helpful? Give feedback.
0 replies
-
A more robust approach would be cursor.execute(sql)
rows = []
fetching = True
while fetching:
try:
rows = cursor.fetchall()
fetching = False
except pyodbc.ProgrammingError:
fetching = cursor.nextset()
print(rows) |
Beta Was this translation helpful? Give feedback.
0 replies
-
pyodbc doesn't support output parameters. There's a workaround documented here |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Please first make sure you have looked at:
Environment
To diagnose, we usually need to know the following, including version numbers. On Windows, be
sure to specify 32-bit Python or 64-bit:
Issue
I have a procedure with 3 parameters, 2 input and 1 output.
From DBeaver if I call the procedure as follows
CALL my_procedure('user','psw', ?)
I have an output of the following type
![image](https://private-user-images.githubusercontent.com/35847603/376166592-cbacad2a-7b91-43da-a2c0-247dde947749.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwMzU1NzQsIm5iZiI6MTczOTAzNTI3NCwicGF0aCI6Ii8zNTg0NzYwMy8zNzYxNjY1OTItY2JhY2FkMmEtN2I5MS00M2RhLWEyYzAtMjQ3ZGRlOTQ3NzQ5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDE3MjExNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc0NDk4NWY2ZDdkNmE2M2M3YmU5Y2M4YjEzYmFhODZkNDQxMDg0YmYzMDg2NjRhN2RjODhlNDkzYjU1NGM0NzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.3gYy6YnxKs0nRnZzEolxE--7U9nqrPa_d2YeDXHnaH4)
Through pyodbc I configured the connection to the DB and ran the same call
`
cnxn = pyodbc.connect("DRIVER=IBM i Access ODBC Driver;SYSTEM=MYIP;UID=USER;PWD=PSW;")
`
Running the print either you fetchall, fetchone or fetchval or the following error
Traceback (most recent call last): File "/Users/alessandrovolpato/Desktop/rapportini-backend/main.py", line 43, in <module> print(cursor.fetchone()) ^^^^^^^^^^^^^^^^^ pyodbc.ProgrammingError: No results. Previous SQL was not a query.
Do you know how I can retrieve the output of the procedure?
Beta Was this translation helpful? Give feedback.
All reactions