aboutsummaryrefslogtreecommitdiff
path: root/odb
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-10-20 10:10:45 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-10-20 10:10:45 +0200
commit3f98883f49d8f0823e6d2d0fca1c5ac87a320f89 (patch)
treeb71c0c1b1346053dcb32c1275eb3de8456697ffd /odb
parenta9a572ba7b152b9bfae56bcbf8717e05c8242e3f (diff)
Do not throw on a unique constraint violation during an insert
Diffstat (limited to 'odb')
-rw-r--r--odb/oracle/statement.cxx14
1 files changed, 13 insertions, 1 deletions
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_,