Any body help me how to use stored procedure and sample code for how to use.
I dont know usage of stored procedure.
Currently i am facing interview questions on stored procedure
Check the documentation on MySQL site, here are the links:
The last link provides some examples with the PHP MySQLi API.
Stored procedures are used to store some actions on your database. So that those actions can be peformed by people without having direct access to the data.
It allows for variable declaration. Its like functions in programming.
DELIMITER // CREATE PROCEDURE `multiply` (OUT var1 INT) BEGIN SET var1 = var1 * 2; END //
When the mutiply procedure is called like so
its given a parameter(in this case
That parameter is then multiplied by two and returned.
Within the "begin" and "end", you can put any type of query.
It limits what users can do on your database and enhances security and ease of use.
The "DELIMITER" tells sql your done with typing a statement.
In the example we used
// as our delimiter.
Hope that helps.