O'Reilly logo

MySQL Stored Procedure Programming by Steven Feuerstein, Guy Harrison

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Conclusion

In this chapter we presented a brief “getting started” tutorial that introduced you to the basics of MySQL stored programs. We showed you how to:

  • Create a simple “Hello World” stored procedure.

  • Define local variables and procedure parameters.

  • Perform conditional execution with the IF statement.

  • Perform iterative processing with simple loops.

  • Include SQL statements inside stored procedures, including how to perform row-at-a-time processing with cursors.

  • Call a stored program from another stored program.

  • Create a stored function (and differentiate stored functions from stored procedures).

  • Create a trigger on a table to automate denormalization.

  • Call a stored procedure from PHP.

Sample PHP program calling a stored procedure
Figure 2-19. Sample PHP program calling a stored procedure

You may now be tempted to put down this book and start writing MySQL stored programs. If so, we congratulate you on your enthusiasm. May we suggest, however, that you first spend some time reading more detailed explanations of each of these areas of functionality in the following chapters? That way, you are likely to make fewer mistakes and write higher-quality code.

Output from our PHP example
Figure 2-20. Output from our PHP example

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required