On Thu, Feb 11, 2010 at 12:48 PM, sultan <sultan.bha...@gmail.com> 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 �...@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.

> 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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to