3 ms·
I agree with you about API's (and would further note that stored procedures are a way to build API's around your database, as are views). However, I disagree t
by einhverfr 14y ago
I agree with you about API's (and would further note that stored procedures are a way to build API's around your database, as are views).
However, I disagree that stored procedures are a bad thing. There are several ways that stored procedures can be used.
1) Named queries (An API around your db!)
2) Set-intensive operations are really best done in SQL. You can do a heck of a lot (of even multi-stage logic!) in a single query when you throw in some in-line views, common table expressions. Writing in stored procedures gives you a single, testable reference for functionality.
3) Exporting application functionality to other programs that may want to use the db (like Excel for example).
4) Unit tests in the db are very, very helpful and highly underrated. Gotta love the fact that rollback means "none of this ever happened."