How can I trap the following Oracle error in a rake task?
Ruby has exception handling:
I can trap
most Oracle errors in the website with “@phone.errors.count > 0”, but
in the rake task the task stops before a check can be done.
The rake task used to work before the Oracle DB administrator decided
to put in foreign key, integrity constraints in Oracle.
You can do a find to see if you are about to cause an exceptions
before you cause it.
OCIError: ORA-00001: unique constraint (OWNER.PHONE_NUMBERS_PK)
violated: INSERT INTO phone_numbers
You need to duplicate this constraint in the model using
thanks for the response.
I have "validates_uniqueness_of :phone_number" in the model, and it
worked fine until the DBA got involved.
Now for this error, Oracle just causes the rake task to abort rather
than returning an error.
The DBA is doing exactly what she should be doing, IMHO.
Clean up your data. Stop breaking the foreign key constraints.
The data is fine, and I am not trying to break any foreign key
I am getting an error on an insert, all I need to know is how to
capture the error before Oracle aborts the rake task.
Can I request you to respectfully to bow out of this conversion, so
that someone else may try to help?
Sure thing. I'm guessing lots of people are dying to assist you with
fixing your broken DBA.