문제

Try/Exception 블록에서 Oracle 오류 번호를 어떻게 추출합니까?

도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top