?
Solved

Stored Procedures role in Developing Database Applications.

Posted on 2006-04-17
3
Medium Priority
?
162 Views
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.
0
Comment
Question by:Anupama_2005
1 Comment
 
LVL 11

Accepted Solution

by:
fargo earned 1000 total points
ID: 16476670
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

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Convert websphere application server default chained Certificates from 1024 to 2048 keysize or higher size and also you can change signatureAlgorithm . Please make sure Websphere Application Server fixpack 7.0.0.23 or Above. The following steps a…
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 …
Integration Management Part 2
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

750 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