List:General Discussion« Previous MessageNext Message »
From:Mauricio Tellez Date:April 27 2009 2:06am
Subject:dynamic table name
View as plain text  
Hi, I'm creating a stored procedure and inside this procedure I have a
CREATE TABLE statement, but I want to make a dynamic table for this table.
Also, this table name is passed as a parameter for another SP, but instead
of get the value of the parameter, I got the name of the parameter. For
example:

CREATE PROEDURE my_test_sp()
BEGIN
     DECLARE my_table CHAR(32);
     SET my_table = UNIX_TIMESTAMP();

     CREATE TABLE my_table (
     id int,
     name char(64));

     call nested_sp(my_table);
END

CREATE PROCEDURE nested_sp(my_table CHAR(32))
BEGIN
   INSERT INTO my_table 1, 'John Doe';
END

of course nested_sp is very silly, but the idea is the same. When I run
this, I found that there is no table name like '20080426...' but I get a
table 'my_table', how can I fix this?

-- 
Mauricio Tellez

Thread
dynamic table nameMauricio Tellez27 Apr
  • Re: dynamic table namePeter Brawley27 Apr