From 3f98883f49d8f0823e6d2d0fca1c5ac87a320f89 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Thu, 20 Oct 2011 10:10:45 +0200 Subject: Do not throw on a unique constraint violation during an insert --- odb/oracle/statement.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'odb') diff --git a/odb/oracle/statement.cxx b/odb/oracle/statement.cxx index 402b5ba..7233e05 100644 --- a/odb/oracle/statement.cxx +++ b/odb/oracle/statement.cxx @@ -681,7 +681,19 @@ namespace odb OCI_DEFAULT)); if (r == OCI_ERROR || r == OCI_INVALID_HANDLE) - translate_error (err, r); + { + sb4 e; + OCIErrorGet (err, 1, 0, &e, 0, 0, OCI_HTYPE_ERROR); + + // The Oracle error code ORA-00001 indicates unique constraint + // violation, which covers more than just a duplicate primary key. + // Unfortunately, there is nothing more precise that we can use. + // + if (e == 1) + return false; + else + translate_error (err, r); + } ub4 row_count (0); r = OCIAttrGet (stmt_, -- cgit v1.1