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.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


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)
SELECT * FROM yourtable WHERE deptNo = in_deptNo;

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Application Servers

From novice to tech pro — start learning today.