How can I trap the following Oracle error in a rake task? I can trap most Oracle errors in the website with “-4MdqKxKvBPysZB9OKgK8SIgTZbYi8/ss@public.gmane.org > 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. rake aborted! OCIError: ORA-00001: unique constraint (OWNER.PHONE_NUMBERS_PK) violated: INSERT INTO phone_numbers -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Feb 11, 2010 at 12:48 PM, sultan <sultan.bhatia-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> How can I trap the following Oracle error in a rake task?Ruby has exception handling: http://ruby-doc.org/docs/ProgrammingRuby/html/tut_exceptions.html> I can trap > most Oracle errors in the website with “-4MdqKxKvBPysZB9OKgK8SIgTZbYi8/ss@public.gmane.org > 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.> rake aborted! > OCIError: ORA-00001: unique constraint (OWNER.PHONE_NUMBERS_PK) > violated: INSERT INTO phone_numbersYou need to duplicate this constraint in the model using validates_uniqueness_of :phone_number. -- Greg Donald destiney.com | gregdonald.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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. On Feb 11, 12:59 pm, Greg Donald <gdon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Feb 11, 2010 at 12:48 PM, sultan <sultan.bha...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > How can I trap the following Oracle error in a rake task? > > Ruby has exception handling: > > http://ruby-doc.org/docs/ProgrammingRuby/html/tut_exceptions.html > > > I can trap > > most Oracle errors in the website with “-4MdqKxKvBPysZB9OKgK8SIgTZbYi8/ss@public.gmane.org > 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. > > > rake aborted! > > OCIError: ORA-00001: unique constraint (OWNER.PHONE_NUMBERS_PK) > > violated: INSERT INTO phone_numbers > > You need to duplicate this constraint in the model using > validates_uniqueness_of :phone_number. > > -- > Greg Donald > destiney.com | gregdonald.com-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Feb 11, 2010 at 1:23 PM, sultan <sultan.bhatia-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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. -- Greg Donald destiney.com | gregdonald.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
The data is fine, and I am not trying to break any foreign key constraints. 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? On Feb 11, 1:49 pm, Greg Donald <gdon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Feb 11, 2010 at 1:23 PM, sultan <sultan.bha...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > 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. > > -- > Greg Donald > destiney.com | gregdonald.com-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Feb 11, 2010 at 1:58 PM, sultan <sultan.bhatia-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The data is fine, and I am not trying to break any foreign key > constraints. > 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. -- Greg Donald destiney.com | gregdonald.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.