0
在try/except塊中,如何提取Oracle錯誤編號?cx_Oracle:我如何獲得ORA-xxxxx錯誤號?
在try/except塊中,如何提取Oracle錯誤編號?cx_Oracle:我如何獲得ORA-xxxxx錯誤號?
try:
cursor.execute("select 1/0 from dual")
except cx_Oracle.DatabaseError, e:
error, = e
print "Code:", error.code
print "Message:", error.message
這導致下面的輸出:
Code: 1476
Message: ORA-01476: divisor is equal to zero