Stored Procedures role in Developing Database Applications.

Posted on 2006-04-17
Last Modified: 2010-03-17
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.
Question by:Anupama_2005
    1 Comment
    LVL 11

    Accepted Solution


    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;


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
    ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now