Manipulation
A procedure is stored inside a database and is not tied to a specific table; therefore,
the interface to manipulate procedures and functions can be found at the database
level, on the Structure page.
The first icon brings this procedure's text into a query box for editing. The second
icon would be used to delete this procedure. When editing the procedure, we notice
that the text was somewhat modified:
DROP PROCEDURE `add_page`//
CREATE DEFINER=`marc`@`%` PROCEDURE `add_page`(IN param_isbn
VARCHAR(25), IN param_pages INT, OUT param_message VARCHAR(100))
BEGIN
IF param_pages > 100 THEN
SET param_message = 'the number of pages is too big';
ELSE
UPDATE book SET page_count = page_count + param_pages WHERE
isbn=param_isbn;
SET param_message = 'success';
END IF;
END
Chapter 18
[ 273 ]
First, a DROP PROCEDURE appears. This is normal because MySQL does not offer
a statement that would permit to change the body of a procedure; therefore, we
have to delete a procedure each time we want to change it. It's true that the ALTER
PROCEDURE statement exists, but it can only change the procedure's characteristics,
for example, adding a comment to it. Then, a DEFINER clause is shown; it was
generated at create time and indicates who created this procedure.
At this point, we make any changes we need to the code and hit Go to save
this procedure.
Pages:
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250