MySQL Stored Procedure Programming


Resources for the Oreilly book by Guy Harrison and Steven Feuerstein

Book Image

Quick Links:

Main
Examples
Tools
Programming languages
Send email

 

Examples and sample data

The examples are included in the following archives organized by chapter.  Each example is named according to the example in text (eg Ex01-01.sql is the text of example 01 in Chapter 01).  There are also some project files in Eclipse and Visual Studio format for the Java and .NET chapters.

Examples - Win zip format
Examples - .tar.gz format

The sample database is in mysqldump file, and can be loaded simply by extracting the .sql file and running it into mysql.  So for instance:

mysql -uusername -ppassword -Ddatabase <mysqlspp.sql

Sample database - winzip format
Sample database - gzip format

Problems loading the example data

There are a couple of possible problems that you might encounter when loading the sample data:

1: 'DELIMITER' syntax error

ERROR 1064 at line 63: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1

This may mean that you are using an older version of the mysql client.  Linux often comes with mysql pre installed in /usr/bin;  you might be useing the mysql client in /usr/bin rather than the one that is in the bin directory of your more recent server.   The solution is to use the version that comes with your server:

[root@guyh3 archive]# which mysql
/usr/bin/mysql
[root@guyh3 archive]# which mysqld_safe
/usr/local/bin/mysqld_safe
[root@guyh3 archive]# /usr/local/bin/mysql -uroot -psecret -Dt2 <mysqlspp.sql

2: '/' syntax error

ERROR 1064 (42000) at line 376: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/' at line 1

This occurs in some earlier versions of MySQL (prior to 5.0.19) when encountering a particular trigger.  MySQL bug 15981 is the likely culprit.  If you get this and downloaded your files before April 15th, please re-download from the link above.  The offending triggers (in fact all triggers) have been removed from the mysqldumpfile.

Let me know if you have any other problems, questions or requests at guy.a.harrison@gmail.com