The dynamic name of the MySQL table stored procedure table variable variable

I want to change the dynamic name of a table in sql query. For example, I have the following stored procedure:

CREATE PROCEDURE NewProc(IN tableName varchar(64),IN message text)
BEGIN
    INSERT INTO tableName VALUES (message);
END;

I need to change tableName at runtime, can I do this or not? Thank.

+3
source share
1 answer

You must use dynamic SQL to prepare and execute the SQL string to achieve what you have described.

( , SQL ..) SQL . .

, SQL- SQL-. , , , .

@OMG Ponies - , , . , , .

0

Source: https://habr.com/ru/post/1763674/


All Articles