Bạn có thể tự hỏi về tuyên bố dấu phân cách, mặc dù. Theo mặc định, MySQL sử dụng dấu chấm phẩy để xác định khi nào một tuyên bố đã kết luận. Tuy nhiên, khi tạo ra một thói quen multistatement được lưu trữ, bạn cần để viết báo cáo nhiều, vào được gửi từ một hình thức Web. Bạn cũng có thể sử dụng thư viện | 830 CHAPTER 32 STORED ROUTINES You may be wondering about the DELIMITER statement though. By default MySQL uses the semicolon to determine when a statement has concluded. However when creating a multistatement stored routine you need to write several statements but you don t want MySQL to do anything until you ve finished writing the stored routine. Therefore you must change the delimiter to another character string. It doesn t have to be . You can choose whatever you please or AA for instance. Executing a Stored Routine Executing a stored routine is accomplished by referencing the stored routine in conjunction with the CALL statement. For example executing the previously created get_inventory procedure is accomplished like so mysql CALL get_inventory @inv mysql SELECT @inv Executing get_inventory will return ------------- @inv ------------- 45 ------------- Creating and Using Multistatement Stored Routines Single-statement stored routines are quite useful but stored routines real power lies in their ability to encapsulate and execute several statements. In fact an entire language is at your disposal enabling you to perform rather complex tasks such as conditional evaluation and iteration. For instance suppose your company s revenues are driven by a sales staff. To coax the staff into meeting its lofty goals bonuses are tacked onto their monthly paychecks with the size of the bonus proportional to the revenues attributed to the employee. The company handles its payroll internally using a custom Java program to calculate and print the bonus checks at the conclusion of each year CHAPTER 32 STORED ROUTINES 831 however a Web-based interface is provided to the sales staff so that it can monitor its progress and bonus size in real time. Because both applications would require the ability to calculate the bonus amount this task seems like an ideal candidate for a stored function. The syntax for creating this stored function looks like this DELIMITER CREATE FUNCTION .