# RoR and stored procedures

**URL:** <https://www.ruby-forum.com/t/ror-and-stored-procedures/103497>\
**Category:** Rails\
**Created:** [May 7, 2007, 5:58am UTC](https://www.ruby-forum.com/t/ror-and-stored-procedures/103497 "2007-05-07T05:58:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wintermute](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e19b73/32.png) [@wintermute](https://www.ruby-forum.com/u/wintermute)\
**Post date:** [May 7, 2007, 5:58am UTC](https://www.ruby-forum.com/t/ror-and-stored-procedures/103497/1 "2007-05-07T05:58:47Z")

</div>

Hi all,

I was wondering about what is the general consensus regarding using SQL  
stored procedures in RoR. Based on the fact that stored procedures are  
not mentioned in most (any) of the RoR manuals I read, I can conclude  
their usage is discouraged.

Is there any particular reason against using SPs?

Thanks

---

<div class="post-metadata">

**Author:** ![wintermute](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e19b73/32.png) [@wintermute](https://www.ruby-forum.com/u/wintermute)\
**Post date:** [May 7, 2007, 6:38am UTC](https://www.ruby-forum.com/t/ror-and-stored-procedures/103497/2 "2007-05-07T06:38:43Z")

</div>

Stored procedures put logic into the database. A place where it’s hard  
to test, hard to version control, hard to access, and typically  
written in a low-level language that’s a pain to deal with. Every now  
and then, you might find yourself in a situation where they’re  
actually worth it for performance reasons. Just like some times it  
makes sense to write a piece of your application in C.

Treat stored procedures like C: Avoid it like the plague until it’s  
your only hope for survival.

---

<div class="post-metadata">

**Author:** ![wintermute](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e19b73/32.png) [@wintermute](https://www.ruby-forum.com/u/wintermute)\
**Post date:** [May 7, 2007, 6:41am UTC](https://www.ruby-forum.com/t/ror-and-stored-procedures/103497/3 "2007-05-07T06:41:44Z")

</div>

I think, in general, people using Rails prefer to have all their code  
within their Rails app rather than use stored procedures.

I use stored procs all the time with Rails, because I prefer to have  
the database “protect itself” from bad data, rather than rely on the  
application/s to do it for me. That’s the big issue for me, although  
I also use stored procs with Rails for other purposes.

It seems to be as much individual preference, and different  
experiences, as anything else - I don’t believe either approach is  
“better” than the other.

Regards

Dave M.
