DECLARE my_table CHAR(32);
    SET my_table = UNIX_TIMESTAMP();

    CREATE TABLE my_table

See the manual page for PREPARE.

PB

-----

Mauricio Tellez wrote:
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?

------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG - www.avg.com Version: 8.0.238 / Virus Database: 270.12.4/2081 - Release Date: 04/26/09 09:44:00

Reply via email to