【问题标题】:cx_Oracle: how do I get the ORA-xxxxx error number?cx_Oracle:如何获取 ORA-xxxxx 错误号?
【发布时间】:2010-09-07 14:56:36
【问题描述】:

在 try/except 块中,如何提取 Oracle 错误号?

【问题讨论】:

    标签: python oracle cx-oracle


    【解决方案1】:
    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
    

    【讨论】:

      猜你喜欢
      • 2020-03-18
      • 2019-12-28
      • 1970-01-01
      • 2012-01-27
      • 1970-01-01
      • 1970-01-01
      • 2020-04-03
      • 2017-05-27
      • 1970-01-01
      相关资源
      最近更新 更多