The Great Stored Procedure Debate
Really, its all been discussed to death already
Stored Procedures vs Do it in Code
Benefits:
Problems
Benefits:
There is a time and a place for Stored Procedures, but they should not be the default position.
OOP: Libraries and Reusability
Procedures
Objects
And in a real language, it's far easier to build a Domain Object library
EDC2 Objects
EDC Squared
Driver Interface
Contracts Updater
Maintenance - Clarity
A Naive Example:
We want to get a tank, if it doesn't have a capacity change it to 100,000lbs
Procedural Style:
ds = DAL.GetDataSet("pkg.GetTankInfo", 100);
if((ds["capacity"] == DBNull.Value) && (ds["uom_id"] == DBNull.Value))
DAL.StoreData("pkg.SaveTank", ds["tank_id"], ds["name"], 100000, 7);
Object-Orientation Style:
tank = TankDao.GetById(100);
if(tank.Capacity == null)
tank.Capacity=new Quantity() {Amount=100000, Uom=Uom.Pounds};
tank.Save();
Which is clearer? The same Tank code can be used everywhere! No need to remember anything else. Intellisense in the IDE can help.
Maintenance - Testing
Automated Testing is far easier when programming properly with OOP
Automated Testing
Maintenance - Tools Available
Programming Languages Have:
PL/SQL has:
Maintenance - Personnel
PL/SQL programmers are far rarer
Writing Stored Procedure Programs
Is Not a DBA Job
Why DO People Use Stored Procedures?
Are any of these real issues? Do any of these apply to us?
Why DO People Use Stored Procedures?
Speed
Security - Authorization
Security - SQL Injection
Ease of Deployment
More: http://weblogs.asp.net/fbouma/archive/2003/11/18/38178.aspx