I have 3 tables:
1. student: {id, name, roll}
2. subject: {id, name}
3. Signs: {student_id, subject_id, marks}
I have a procedure that returns all the student and their labels (say getAllMarks ()), I want to create another procedure that returns the marks of this roll no (say getRollMarks (int rollno)). Thus, there are two ways to create a procedure:
1. write the appropriate SQL to get the result in the getRollMarks procedure.
2. call getAllMarks in getRollMarks, and then apply the where clause to the result returned by getAllMarks.
Can anyone suggest the pros and cons of the two methods above? I have 2 pluses of method 2:
1.SQL queries will not be repeated in different procedures.
2. If something changes in one table, the change will be performed in one place / in the procedure, and not in every procedure that uses this table.
PS: Tables are just an example, in fact they are large tables with many parameters for the query. The question can be simplified how , should we write repeated queries in different procedures or use existing procedures with the required sentence (where, order, union, etc.)?
join mysql stored-procedures
thekosmix
source share