Hello,
I am moving my first steps with stored procedures in Mysql and I was
trying to write a stored procedure
using a tablename given as a variable. In this example the local
variable m_sequence has the value of the
table I want to use.
CREATE PROCEDURE p_new_id (IN tablename VARCHAR(128), OUT new_id INT)
BEGIN
DECLARE m_new_id INT DEFAULT 0;
DECLARE m_sequence VARCHAR(128);
SELECT CONCAT("_sequence_", tablename) INTO m_sequence;
INSERT INTO m_sequence VALUES (NULL);
SELECT last_insert_id() INTO m_new_id;
DELETE FROM m_sequence WHERE sequence < m_new_id;
SET new_id = m_new_id;
END;
However when I try to execute it, it gives me this error message:
"Table 'db.m_sequence' doesn't exist"
Meaning that a table literally called m_sequence was not found, but i
would like to use the table inside
the m_sequence variable instead.
Anyone knows if it's possible and how?
Thank you very much
Stefano Locati - Obliquid
http://software.obliquid.it/
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]