Create bookmark
MySQL Stored Procedure Programming
Building High-Performance Web Applications in MySQL
Notes
Please login to add notes
- Table of Contents
- + Preface
- Part I
-
+
Introduction to MySQL Stored Programs
- + MySQL Stored Programming Tutorial
-
+
Language Fundamentals
-
+
Blocks, Conditional Statements, and Iterative Programming
- + Using SQL in Stored Programming
-
+
Error Handling
- Part II
-
+
Creating and Maintaining Stored Programs
-
+
Transaction Management
-
+
MySQL Built-in Functions
- + String Functions
- + Numeric Functions
-
+
Date and Time Functions
- ADDTIME
- CONVERT_TZ
- CURRENT_DATE
- CURRENT_TIME
- CURRENT_TIMESTAMP
- DATE
- DATE_ADD
- DATE_FORMAT
- DATE_SUB
- DATEDIFF
- DAY
- DAYNAME
- DAYOFWEEK
- DAYOFYEAR
- EXTRACT
- GET_FORMAT
- MAKEDATE
- MAKETIME
- MONTHNAME
- NOW
- SEC_TO_TIME
- STR_TO_DATE
- TIME_TO_SEC
- TIMEDIFF
- TIMESTAMP
- TIMESTAMPADD
- TIMESTAMPDIFF
- WEEK
- WEEKDAY
- YEAR
- YEARWEEK
- Other Date and Time Functions
- + Other Functions
- Conclusion
-
+
Stored Functions
-
+
Triggers
- Part III
-
+
Using MySQL Stored Programs in Applications
-
+
Using MySQL Stored Programs with PHP
- Options for Using MySQL with PHP
-
+
Using PHP with the mysqli Extension
- Enabling the mysqli Extension
- Connecting to MySQL
- Checking for Errors
- Executing a Simple Non-SELECT Statement
- Retrieving a Result Set
- Managing Transactions
- Using Prepared Statements
- Retrieving Result Sets from Prepared Statements
- Getting Result Set Metadata
- Processing a Dynamic Result Set
- Calling Stored Programs with mysqli
- Handling Output Parameters
- Retrieving Multiple Result Sets
-
+
Using MySQL with PHP Data Objects
- Connecting to MySQL
- Executing a Simple Non-SELECT Statement
- Catching Errors
- Managing Transactions
- Issuing a One-Off Query
- Using Prepared Statements
- Binding Parameters to a Prepared Statement
- Getting Result Set Metadata
- Processing a Dynamic Result Set
- Calling Stored Programs with PDO
- Binding Input Parameters to Stored Programs
- Handling Multiple Result Sets
- Handling Output Parameters
- A Complete Example
- Conclusion
-
+
Using MySQL Stored Programs with Java
-
+
Using MySQL Stored Programs with Perl
-
+
Using MySQL Stored Programs with Python
-
+
Using MySQL Stored Programs with .NET
- Part IV
-
+
Stored Program Security
-
+
Tuning Stored Programs and Their SQL
-
+
Basic SQL Tuning
-
+
Advanced SQL Tuning
- + Optimizing Stored Program Code
-
+
Best Practices in MySQL Stored Program Development
- + The Development Process
-
+
Coding Style and Conventions
- STYL-01: Adopt a consistent, readable format that is easy to maintain
- STYL-02: Adopt logical, consistent naming conventions for modules and data structures
- STYL-03: Self-document using block and loop labels
- STYL-04: Express complex expressions unambiguously using parentheses
- STYL-05: Use vertical code alignment to emphasize vertical relationships
- STYL-06: Comment tersely with value-added information
-
+
Variables
- DAT-01: Use a consistent and meaningful variable naming style
- DAT-02: Avoid overriding variable declarations within “inner” blocks
- DAT-03: Replace complex expressions with functions
- DAT-04: Remove unused variables and code
- DAT-05: Don’t assume that the result of an expression is TRUE or FALSE; it could be NULL
- DAT-06: Employ “user” variables for global data sparingly
- DAT-07: Create stored programs in strict mode to avoid invalid data assignments
- + Conditional Logic
- + Loop Processing
-
+
Exception Handling
- EXC-01: Handle exceptions that cannot be avoided but can be anticipated
- EXC-02: Use named conditions to improve code readability
- EXC-03: Be consistent in your use of SQLSTATE and MySQL error codes in exception handlers
- EXC-04: Avoid global SQLEXCEPTION handlers until MySQL implements SIGNAL and SQLCODE features
-
+
SQL in Stored Programs
- SQL-01: Start a transaction explicitly with the START TRANSACTION statement
- SQL-02: Don’t leave transactions “dangling”
- SQL-03: Avoid use of savepoints—they can obscure program logic and reduce program efficiency
- SQL-04: Use an appropriate locking strategy
- SQL-05: Keep transactions small
- SQL-06: Always reset the NOT FOUND variable after completing a cursor loop
- SQL-07: Use SELECT FOR UPDATE when retrieving rows for later update
- SQL-08: Avoid including SQL in functions that may be used in SQL
- + Dynamic SQL
-
+
Program Construction
- PRG-01: Encapsulate business rules and formulas behind accurately named functions
- PRG-02: Standardize module structure using function and procedure templates
- PRG-03: Limit execution section sizes to a single page (50-60 lines) using modularization
- PRG-04: Avoid side-effects in your programs
- PRG-05: Avoid deep nesting of conditionals and loops
- PRG-06: Limit functions to a single RETURN statement in the executable section
- PRG-07: Use stored programs to implement code common to multiple triggers
-
+
Performance
- PER-01: Concentrate on tuning SQL to improve stored program performance
- PER-02: Carefully create the best set of indexes for your application
- PER-03: Avoid accidental table scans
- PER-04: Optimize necessary table scans
- PER-05: Avoid using stored programs for computationally expensive routines
- PER-06: Move loop invariant expressions outside of loops
- PER-07: Optimize conditional structures
- PER-08: Structure IF and CASE statements so more likely expressions appear earliest in the list
- Conclusion
- Index
The implementation of stored procedures in MySQL 5.0 a huge milestone -- one that is expected to lead to widespread enterprise adoption of the already extremely popular MySQL database. If you are serious about building the web- based database applications of the future, you need to get up to speed quickly on how stored procedures work -- and how to build them the right way. This book, destined to be the bible of stored procedure development, is a resource that no real MySQL programmer can afford to do without.
In the decade since MySQL burst on the scene, it has become the dominant open source database, with capabilities and performance rivaling those of commercial RDBMS offerings like Oracle and SQL Server. Along with Linux and PHP, MySQL is at the heart of millions of applications. And now, with support for stored procedures, functions, and triggers in MySQL 5.0, MySQL offers the programming power needed for true enterprise use.
MySQL's new procedural language has a straightforward syntax, making it easy to write simple programs. But it's not so easy to write secure, easily maintained, high-performance, and bug-free programs. Few in the MySQL world have substantial experience yet with stored procedures, but Guy Harrison and Steven Feuerstein have decades of combined expertise.
In MySQL Stored Procedure Programming, they put that hard-won experience to good use. Packed with code examples and covering everything from language basics to application building to advanced tuning and best practices, this highly readable book is the one-stop guide to MySQL development. It consists of four major sections:
- MySQL stored programming fundamentals -- tutorial, basic statements, SQL in stored programs, and error handling<
li>
Building MySQL stored programs -- transaction handling, built-in functions, stored functions, and triggers
MySQL stored programs in applications -- using stored programs with PHP, Java, Perl, Python, and .NET (C# and VB.NET)
Optimizing MySQL stored programs -- security, basic and advanced SQL tuning, optimizing stored program code, and programming best practices
A companion web site contains many thousands of lines of code, that you can put to use immediately.
Guy Harrison is Chief Architect of Database Solutions at Quest Software and a frequent speaker and writer on MySQL topics. Steven Feuerstein is the author of Oracle PL/SQL Programming, the classic reference for Oracle stored programming for more than ten years. Both have decades of experience as database developers, and between them they have authored a dozen books.
Test the closed alpha on paperc.com
Book Details
Authors
Guy Harrison and Steven Feuerstein
Categories
Computers > Database Management > General
Publishers
Publication year : 2008
License: All rights reserved ©
Times read: 1,022

