I'm trying call stored procedure using following code
conn = ibm_db.connect("database","username","password")
sql = "CALL DB2INST1.KPI_VALIDATE()"
stmt = ibm_db.exec_immediate(conn, sql)
But this procedure does not return any rows & It will only return code. Now I need to handle error whether procedure run successfully or not. Could anyone help me how to handle this?
Thanks
For test purposes, I've created a table:
and my procedure will simply insert a row into this table - this will allow me to easily force an error with a duplicate key:
now with Python:
so if a procedure hits an exception then you'll get it, you just need to handle exception
Try/Except
block:Or you are actually interested with
CALL
return code/status? E.g.:test:
then this is a bit tricky. With CLI trace enabled (I have
ibm_db
installed in my local path so it fetched CLI package there too):trace does show the returns status:
but I don't see anywhere in python-ibmdb API a way to fetch it... (e.g.
ibm_dbcallproc
doesn't have such option). Which means, that unless I'm missing something, you would have to raise an issue on Github to extent the API