diff options
author | Constantin Michael <constantin@codesynthesis.com> | 2011-10-20 10:10:45 +0200 |
---|---|---|
committer | Constantin Michael <constantin@codesynthesis.com> | 2011-10-20 10:10:45 +0200 |
commit | 3f98883f49d8f0823e6d2d0fca1c5ac87a320f89 (patch) | |
tree | b71c0c1b1346053dcb32c1275eb3de8456697ffd | |
parent | a9a572ba7b152b9bfae56bcbf8717e05c8242e3f (diff) |
Do not throw on a unique constraint violation during an insert
-rw-r--r-- | odb/oracle/statement.cxx | 14 |
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_, |