Stored Procedure Programming for MySQL5 - Part 2
|
|
|
Click to rate: |
|
|
|
192 votes / avg. rating 7.01%
|
|
Now that we've become familiar with the fundamentals of stored procedures it is time to start playing with the “Big Boy Toys”. This article will go over stored procedures's built in error handling, the security features available, various “extras” available, what isn't allowed in a stored procedure, and some basic administration of the stored procedures. So lets stop talking and bust open the toy box and start playing!
Let's jump right in with the sample stored procedure we will be working with. It isn't particularly elaborate but it does touch on just about everything we will be going over. So it will be a decent reference to the various sections we are talking about. Sample CodeThe CREATE statement for the table it will work with:
CREATE TABLE test (
ID INT AUTO_INCREMENT NOT NULL,
COL1 INT NOT NULL DEFAULT 0,
PRIMARY KEY (ID));
The stored procedure itself:
Verification the stored procedure works:Note: Remember that when calling a stored procedure you must provide all the parameters specified by the stored procedure. So “test', ”COL1“, 3 and 5 will go to the IN vars of the stored procedure and the @error var will hold anything that comes out of the stored procedure.
 |
|
 |
|
Tags:
mysql
Tags Help
Tags are keywords associated with a web page that help classifying information. You can find a good explanation here.
To add one or more tags to this page, simply enter them below (separate them with a comma) and hit enter or click on the "Go" button.
|
|
 |
|
 |
|