By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,079 Members | 940 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,079 IT Pros & Developers. It's quick & easy.

Naming convention in procedure for readability

P: 36
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
Share this Question
Share on Google+
5 Replies


mwasif
Expert 100+
P: 801
Moved the thread to MySQL Forum, the right place to ask the questions about MySQL.
Sep 6 '07 #2

10K+
P: 13,264
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

P: 36
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

10K+
P: 13,264
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

P: 36
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

Post your reply

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