• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

Stored Procedures role in Developing Database Applications.

I'm very new to this PHP.

I've to develop one (web) application using MySQL as backend, and PHP as front-end.

My team-lead is insisting me to use Stored-procedures while getting data from MySQL.

So, obiviously I've searched in the net. But I could not able to get clear solution.

Then I got doubt whether they are useful or not. Why because, in most of the books as well as websites all are giving solution with Prepared statements, but not with Stored procedures.

If stored procedures are also good, Can any-one help me in getting the solution for the following problem... please !

My requirement is to pass parameters to retrieve data from database like below.

For Example:
If there is a table like the following in MySQL Database:

Dept No    DName                   Location
   10         Accounting              New York
   20         Research                 Dallas
   30         Computers               Bangalore
   40         Electronics               Visakhapatnam.

Now I could be able to retrieve Department Name(DName), Location values based on Dept No, that too using stored procedures.
                    Thanking you very much.
0
Anupama_2005
Asked:
Anupama_2005
1 Solution
 
fargoCommented:
Hi,

In my opinion, for making the select statements like as u mentioned ..there is no need to have stored procedure handling. One can also do the above using the stored procedure but it doesn't make much sense. Stored procedures are handy in making some complex insert/update/delete within one transaction which touches many tables etc.

For your case with stored proc should be the  following.
CREATE PROCEDURE getDepartments(IN in_deptNo INT)
BEGIN
SELECT * FROM yourtable WHERE deptNo = in_deptNo;
END

Otherwise, i would make a simple query with
SELECT * FROM yourtable WHERE deptNo = in_deptNo;


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The Lifecycle Approach to Managing Security Policy

Managing application connectivity and security policies can be achieved more effectively when following a framework that automates repeatable processes and ensures that the right activities are performed in the right order.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now