How to get errors and messages like "DB20000I The SQL command completed successfully"?

79 views
Skip to first unread message

makafonov

unread,
Jul 4, 2020, 8:34:45 AM7/4/20
to ibm_db

Hello. Hoping someone can help. I try to get errors and messages like "DB20000I The SQL command completed successfully". It's my code:

ibm_db_conn = ibm_db.connect(conn_str, '', '')
sql = "UPDATE VMVP.settings SET setting_value='2040' WHERE setting_name = 'bad_option'"
try:
    stmt = ibm_db.exec_immediate(ibm_db_conn, sql)
except Exception:
    print('Transaction couldn\'t be completed:', ibm_db.stmt_errormsg())
else:
    print('Transaction complete.') ibm_db.close(ibm_db_conn)

When I specify an invalid parameter in the SQL statement like "bad_option", I receive every time "Transaction complete" without any errors.

Василий Макафонов

unread,
Jul 4, 2020, 8:34:45 AM7/4/20
to ibm_db
How to get errors?

Saba Kauser

unread,
Jul 6, 2020, 10:17:19 PM7/6/20
to ibm_db
Hi ,
We have APIs documentation with examples here :

You  can extract error messages using ibm_db.stmt_errormsg() and

ibm_db.conn_errormsg() .


The one like Db200001 are CLP specific  messages.

Saba Kauser

unread,
Jul 7, 2020, 12:03:02 AM7/7/20
to ibm_db
Also, from your update statement it seem like you have setting_name as char column and 'bad option' is just like the other value '12345'. Why are you expecting an error?

makafonov

unread,
Jul 7, 2020, 2:39:19 AM7/7/20
to ibm_db
I expected to get something like this: "SQL0100W No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table. SQLSTATE=02000", because I don't have a row in a table with value bad_option in column setting_name. But every time exceptions don't raise and I receive "Transaction complete".
вторник, 7 июля 2020 г. в 09:03:02 UTC+5, Saba Kauser:

Saba Kauser

unread,
Jul 22, 2020, 6:09:38 AM7/22/20
to ibm_db
Can you raise a issue in github here -> https://github.com/ibmdb/python-ibmdb/issues
I can update the code to return warning message for sqlcode 100.

Thanks!
Reply all
Reply to author
Forward
0 new messages