

However, the mysql command-line utility also uses as a delimiter. The default MySQL statement delimiter is (as you have seen in all of the MySQL statement used thus far). Mysql Command-line Client Delimiters If you are using the mysql command-line utility, pay careful attention to this note. No data is returned because the code does not call the stored procedure, it simply creates it for future use. When MySQL processes this code it creates a new stored procedure named productpricing. BEGIN and END statements are used to delimit the stored procedure body, and the body itself is just a simple SELECT statement. This stored procedure has no parameters, but the trailing () is still required. Had the stored procedure accepted parameters, these would have been enumerated between the ( and ). The stored procedure is named productpricing and is thus defined with the statement CREATE PROCEDURE productpricing(). Ignore the first and last lines for a moment we'll come back to them shortly.

Here is the code: CREATE PROCEDURE productpricing() To give you a taste for what is involved, let's look at a simple examplea stored procedure that returns the average product price.

Creating Stored ProceduresĪs already explained, writing a stored procedure is not trivial. Stored procedures might or might not display results, as you will see shortly. Take a look at this example: CALL a stored procedure named productpricing is executed it calculates and returns the lowest, highest, and average product prices. CALL takes the name of the stored procedure and any parameters that need to be passed to it. MySQL refers to stored procedure execution as calling, and so the MySQL statement to execute a stored procedure is simply CALL.
