Prev | Current Page 921 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

A stored routine is a set of SQL statements
stored in the database server and executed by calling an assigned name within a query,
much like a function encapsulates a set of commands that is executed when the function
name is invoked. The stored routine can then be maintained from the secure
confines of the database server, without ever having to touch the application code.
As of version 5.0, MySQL supports this long-awaited feature. This chapter tells you
all about how MySQL implements stored routines, both by discussing the syntax and by
showing you how to create, manage, and execute stored routines. You??™ll also learn how to
820 CHAPTER 32 ?–  S TORED ROUTINES
incorporate stored routines into your Web applications via PHP scripts. To begin, take a
moment to review a more formal summary of their advantages and disadvantages.
Should You Use Stored Routines?
Rather than blindly jumping onto the stored routine bandwagon, it??™s worth taking a
moment to consider their advantages and disadvantages, particularly because their
utility is a hotly debated topic in the database community. This section summarizes
the pros and cons of incorporating stored routines into your development strategy.
Stored Routine Advantages
Stored routines have a number of advantages, the most prominent of which are highlighted
here:
??? Consistency: When multiple applications written in different languages are
performing the same database tasks, consolidating these like functions within
stored routines decreases otherwise redundant development processes.


Pages:
909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933