473,320 Members | 1,802 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,320 software developers and data experts.

Naming convention in procedure for readability

Hi,

I have a procedure like this

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE `get_employee_details`( employeeid int)
  2. BEGIN
  3.    select * from employee_master where emp_id = employeeid ;
  4. END;
Here i may get confused with the local variables and database objects. So it gives poor readability.

How will i make standard naming convention to distinguish local variables and database objects.

Thanking you,
Dileep
Sep 6 '07 #1
5 8116
mwasif
802 Expert 512MB
Moved the thread to MySQL Forum, the right place to ask the questions about MySQL.
Sep 6 '07 #2
r035198x
13,262 8TB
Hi,

I have a procedure like this

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE `get_employee_details`( employeeid int)
  2. BEGIN
  3.    select * from employee_master where emp_id = employeeid ;
  4. END;
Here i may get confused with the local variables and database objects. So it gives poor readability.

How will i make standard naming convention to distinguish local variables and database objects.

Thanking you,
Dileep
Prefix
normal variables with v_ as in v_variable
parameters with p_ as in p_parameter
bind variables with a g_ as in g_bindVariable
constants with a c_ as in c_myConstant

And add a suffix to all composite types explaining which type it is

Cursor emp_cursor
Record emp_record

e.t.c
Sep 6 '07 #3
Prefix
normal variables with v_ as in v_variable
parameters with p_ as in p_parameter
bind variables with a g_ as in g_bindVariable
constants with a c_ as in c_myConstant

And add a suffix to all composite types explaining which type it is

Cursor emp_cursor
Record emp_record

e.t.c
I have a table like this,
visit_master( v_rid int, v_name varchar(100), v_time date_time).
In this case again i may get confused with the objects and variables when used in procedure.
Because prefix with "v_" is assumed to be variables.
Sep 19 '07 #4
r035198x
13,262 8TB
I have a table like this,
visit_master( v_rid int, v_name varchar(100), v_time date_time).
In this case again i may get confused with the objects and variables when used in procedure.
Because prefix with "v_" is assumed to be variables.
When referring to the table columns just fully qualify them as in
visit_master.v_rid e.t.c
Sep 19 '07 #5
When referring to the table columns just fully qualify them as in
visit_master.v_rid e.t.c
You have given a right solution itself. But here in all queries i have to say <table name>.<field name> which makes bigger querry.
Instead is there any other feature provided by MySQL like SQL Server provides "@" as prefix to alll variables. So the programmers will not make any mistake in distinguishing table fields and variables.

Does MySQL provides such feature?
Sep 19 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

48
by: Robert Jacobson | last post by:
Hello all, If I have a class called "Foo," is there a preferred naming convention for iterating through each Foo instance in a collection of Foos? I've seen several different variations, even...
2
by: John Salerno | last post by:
After reading the PEP, I'm still not quite sure if there is a recommended (or widely preferred) method of naming variables. Here are the relevant bits: > Global Variable Names > > (Let's...
114
by: Jonathan Wood | last post by:
I was just wondering what naming convention most of you use for class variables. Underscore, "m_" prefix, camel case, capitalized, etc? Has one style emerged as the most popular? Thanks for...
2
by: Fir5tSight | last post by:
Hi, I have a stored procedure that looks like the follows: ------------------------------------------------------------------------------------- SELECT ClientName AS 'Client Name', Location,...
8
by: mrashidsaleem | last post by:
Can anyone guide me what is wrong with the naming conventions suggested below? I know that this is not recommended by many (including Microsoft) but I need to know what exactly is the rationale...
23
by: Thorsten Kampe | last post by:
Okay, I hear you saying 'not another naming conventions thread'. I've read through Google and the 'naming conventions' threads were rather *spelling conventions* threads. I'm not interested...
1
by: getmeidea | last post by:
Hi, I have a procedure like this Here i can distinguish variables in procedure and database objects. So it gives me poor readability. Is there any standard way of naming convention...
1
by: mk | last post by:
http://www.python.org/dev/peps/pep-0008/ "Function Names Function names should be lowercase, with words separated by underscores as necessary to improve readability." However, this PEP does...
36
by: pereges | last post by:
Apart from the some rules set by the C standard what , in your opinion, are good naming convetions for variables ? Can you please give an example or two ?
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.