473,411 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Stored Procedure compilation question: Doing disparate things in aproc

To minimize the very large number of stored procedures typically
associated with an application, I have gotten in the habit of
combining a select, insert, update, and delete all in one procedure,
and passing an argument to indicate which to use. (I use default
values for all input params to avoid having to declare them for
selects and deletes.) So I'll have just one PersonAdmin proc instead
of PersonGet, PersonInsert, PersonUpdate, and PersonDelete procs

While this is nice for housekeeping, I wonder what the compiler does
with such an architecture,and I fear the worst. The select returns a
recordset; the others don't.

Is this a bad idea?

If it is, I really wish SQL would permit some sort of user folder
structure in the proc list.
Dec 7 '07 #1
2 2381
I've seen systems where those types of procs are combined, but the
issue I have with them is that your procedures are no longer small
modular bits. This makes them hard to debug and even more difficult to
combine within other procedures.

I completely agree with you about proc folders, but for now only
strong naming conventions will save us.
Dec 8 '07 #2
JeffRoughgarden (jr**********@gmail.com) writes:
To minimize the very large number of stored procedures typically
associated with an application, I have gotten in the habit of
combining a select, insert, update, and delete all in one procedure,
and passing an argument to indicate which to use. (I use default
values for all input params to avoid having to declare them for
selects and deletes.) So I'll have just one PersonAdmin proc instead
of PersonGet, PersonInsert, PersonUpdate, and PersonDelete procs

While this is nice for housekeeping, I wonder what the compiler does
with such an architecture,and I fear the worst. The select returns a
recordset; the others don't.

Is this a bad idea?
As everything else: it depends. If you want some users to be able to
retrieve data, but not be able to update, this approach has its
problems.

Personally, I think its normal to have INSERT and UPDATE in the same
procedure, as they tend to have a lot of logic in common. We also have
cases where we house the DELETE in the same procedure, but that
means you have to pass a lot parameters that are not needed for DELETE.

Myself, I would always put the SELECT in a separate procedure.
If it is, I really wish SQL would permit some sort of user folder
structure in the proc list.
In SQL 2005 you can use schemas to create different name spaces. (You
can in SQL 2000 as well, but as schema = owner in SQL 2000, it's quite
messy.)

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Dec 8 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Lili | last post by:
I'm having problems creating a simple stored procedure in DB2. Can someone help? Here is the screen dump when I tried to load the stored procedure. Thanks for any help. Create procedure...
8
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have...
8
by: Mark Flippin | last post by:
This is for a reporting problem using: Access 2000 SQL Server 2000 Both at SP3 I've a stored procedure in SQL Server 2000 which builds a result set from a disparate set of tables, utilizing...
2
by: Not Me | last post by:
Hey, Coming back to a piece of work I did a while back, which used a stored procedure to populate a list box. The SP takes a single parameter, and I think this is the reasoning for using 'exec'...
14
by: Roy | last post by:
Apologies for the cross-post, but this truly is a two-sided question. Given the option of creating Looping statements within a stored proc of sql server or in the code-behind of an .net webpage,...
1
by: Mike McGavin | last post by:
Hello everyone. Can anyone suggest if there's a way to force a plpgsql stored procedure to be recompiled every time that it's called, based on the values of the parameters that it's given? I...
28
by: mooreit | last post by:
The purpose for my questions is accessing these technologies from applications. I develop both applications and databases. Working with Microsoft C#.NET and Microsoft SQL Server 2000 Production and...
3
by: CK | last post by:
Hi All, Quick question, I have always heard it best practice to check for exist, if so, drop, then create the proc. I just wanted to know why that's a best practice. I am trying to put that theory...
3
by: comp_databases_ms-sqlserver | last post by:
This post is related to SQL server 2000 and SQL Server 2005 all editions. Many of my stored procedures create temporary tables in the code. I want to find a way to find the query plan for these...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.