cx_Oracle:如何获取ORA-xxxxx错误编号?
在一个try/except代码块中,我该如何提取Oracle的错误编号?
1 个回答
13
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