Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 sproc types

Author  Topic 

nic
Posting Yak Master

209 Posts

Posted - 2003-01-09 : 13:10:59
Hi,
I have an application where all the database communication is done via stored procedures. I name/group all the sprocs with either load/insert/update/delete. (i.e. xx_load_userData).

This works well. Sometimes it makes sense to do a combination of different types of statements in one sproc. (i.e. mostly "select" data but also throw in an "update") In these scenarios the naming conventions kinda falls apart. With so many sprocs it is a little confusing to have an "update" statemtent in a sproc named xx_load_xxxxxx.

I was thinking on seperating the "update" statement into a seperate sproc and have the "load" statement call it. This way at least all update statements will be in "update" sprocs.

Whenever I start a new project I try to be as organized as possible since in the end there will be ALOT of sprocs, so a good naming convention is key.

Has anyone run into this before?

Nic

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-01-09 : 13:17:26
At my last job, we did it very similar to this.

I took a look at various stored procedures that were written and found a few examples of mixed statements. It looks like the developers named them according to the purpose of the stored procedure and not what statements it called. For example, I found one that did a select, delete, and an update, but the purpose was to delete records, so it was named how deletes are named.

We do not follow this at my new job, but usually the name of the stored procedure will indicate its purpose which usually means it will say if it is getting rows, updating rows, etc...

Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2003-01-09 : 13:56:01
I use the word "Get" when I'm getting a set of records, "Is" for getting a single output boolean parameter, "update" to change several fields in a record, "Set" to change a single field in a record (usualluy a bit field).

Examples might be:
p_Customer_GetCustomersByRegion
p_Customer_IsCustomerInRegion
p_Customer_UpdateCustomer
p_Customer_SetCustomerRegion

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

ajthepoolman
Constraint Violating Yak Guru

384 Posts

Posted - 2003-01-09 : 16:01:38
We use a convention that helps us immediately recognize which table an SP is tied to.

Take an employee table for example.

Table name: tblEmployee
SP names:
qryEmployeeSel (select, or load query)
qryEmployeeIns (insert query)
qryEmployeeUpd (update query)
qryEmployeeDel (delete query)
qryEmployeeLst (List query (to populate a combobox for instance))
qryEmployeeXlst (List query (to populate a grid))
qryEmployee_By_PersonIDUpd (to update an employee record by using the Person ID instead of the EmployeeID)

In doing this, we have been able to create SQL wizards that will build all of our stored procs, and visual basic and ASP forms. Yes, it will build the actual forms for us, all we do is add them to our projects.

Naming conventions can be whatever you want them to be, but you must be consistant.

Hope this helps.

Aj



Go to Top of Page
   

- Advertisement -