I have a C application that uses OCI to update a table.

I have a buffer of records and use a parameterized update statement like this:
UPDATE AMB set name = :1 where (id = :2).

It may happen that some records in the input buffer do not exist. It may also happen that after an update, the record is rejected due to constraints on the table.

I need to report the first offending record, commit and exit my application. Records that do not exist are not offending records.

If I use OCIStmtExecute with OCI_BATCH_ERRORS, I can find the violating records using OCI_ATTR_DML_ROW_OFFSET. However, OCIStmtExecute does NOT stop on the first violating record. It keeps going until it loads the whole input buffer.

If I use OCIStmtExecute with OCI_DEFAULT, it stops on the first error, but OCI_ATTR_ROW_COUNT returns the numbers of rows affected in the target table, not the violating record in the input buffer.

Is there a way to do what I need?

I get this behavior on a bunch of Oracle versions and platforms.