mysql>
mysql> delimiter $$
mysql>
mysql> CREATE PROCEDURE myProc()
->
-> BEGIN
-> DECLARE major_version INT;
->
-> SET major_version=SUBSTR(version(),1,INSTR(version(),'.')-1);
-> IF major_version>=5 THEN
-> SELECT 'Good thing you are using version 5 or later';
-> ELSE
-> SELECT 'This version of MySQL does not support stored procedures',
-> 'you must be dreaming';
-> END IF;
->
-> END$$
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> delimiter ;
mysql> call myProc();
+---------------------------------------------+
| Good thing you are using version 5 or later |
+---------------------------------------------+
| Good thing you are using version 5 or later |
+---------------------------------------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> drop procedure myProc;
Query OK, 0 rows affected (0.00 sec)
mysql>