I am writing stored procedures for several operations in a database, I just wanted to know:
- Is it better to design a single procedure for a table which can perform add, modify, delete operations or…
- Should I design seperate procedures for each operations
Which approach would be better?
I would say that a separate stored procedure for each operation is best. Otherwise you get too much logic inside your procedures.
Besides, most operations require different parameters. For a delete you only need the primary key but for an insert you must provide values all not nullable columns. You do not want to provide dummy insert parameters when you just want to delete a record.