I have a simple stored procedure which works as intended.
As soon as I add a UNION in the SELECT I get the error message
ERROR 1064 (42000): 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 'select phon_Lvl INTO Lvl
Are UNION's currently not allowed in a stored procedure?
mysql> delimiter //
mysql> create procedure ph()
-> BEGIN
-> DECLARE LVL Char(10);
-> select phon_Lvl INTO Lvl
-> FROM phones
->
-> limit 1;
-> SET @Lvl:=Lvl;
-> END//
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
mysql>
mysql> call ph();
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> Select @Lvl;
+------+
| @Lvl |
+------+
| locn |
+------+
1 row in set (0.00 sec)
mysql>
mysql> drop procedure if exists ph;
Query OK, 0 rows affected (0.01 sec)
mysql> delimiter //
mysql> create procedure ph()
-> BEGIN
-> DECLARE LVL Char(10);
-> select phon_Lvl INTO Lvl
-> FROM phones
-> UNION
-> Select "a" into LVL
-> limit 1;
-> SET @Lvl:=Lvl;
-> END//
ERROR 1064 (42000): 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 'select phon_Lvl INTO Lvl
FROM phones
UNION
Select "a" into LVL
limi' at line 4
mysql> delimiter ;
mysql>
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]