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

2 Years
Discussion Span
Last Post by ramsiva

Yet another Link

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.


CREATE PROCEDURE `multiply` (OUT var1 INT)
    SET var1 = var1 * 2;
END //

When the mutiply procedure is called like so

CALL multiply(5)

its given a parameter(in this case 5).

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.