Procedures are control blocks created in the database in order to optimize a function that will be used at various times, they work so similar to the methods in programming. In MySQL, procedures are used to facilitate routine transaction with the bank and also to help in the process of data manipulation when working with desktop or web interfaces.

To create a procedure in MySQL is necessary to use some commands that together enable its inception, the syntax is as follows:

CREATE PROCEDURE ‘[procedure name]’ ([Parameters])




As a practical example we will perform a SELECT with filters from a variable informed user.

CREATE PROCEDURE ‘sp_product’ (IN _id INT)


Select *

From products

Where id_product = _id


Note that before the variable declaration syntax is used IN stating that this variable will be informed by the user, another way to use variables is to use the command OUT where this variable is returned with some value to the user.

To use the procedure established just use the call command and then the procedure name with parameters, if it has.

call sp_product(1)


Understand the workings of MySQL is paramount for projects that want to increase its cost-effective, learn more about the advantages of PHP combined with MySQL on our official site by clicking the link above.

You might also like…

Scriptcase & Web Services

This time I will explain how to work with web services inside the Scriptcase, directly with PHP and...

More updates in 9.4 version

Recently version 9.4 was released bringing a new design concept to the generated applications of Sc...

Taking a look at version 9.4

Scriptcase released its version 9.4, and this one brings many interesting news, specially regarding...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at Learn more about our Privacy Police.