/usr/portage

Way to dynamically create table names? 0

Assume I have the following stored procedure:

CREATE PROCEDURE addToList(IN string VARCHAR(128), IN tbl VARCHAR(128))
BEGIN
    DECLARE query TEXT;
    SET query = REPLACE( 'INSERT INTO __table__ SET string = ?', '__table__', tbl );
    PREPARE stmt FROM query;
    SET string = string;
    EXECUTE stmt USING string;
END;

This will sadly not work, because it is not possible to prepare a query from a variable. A workaround is to write an endless long CASE-construct, which is not elegant and not flexible. Do you have any idea how to solve this problem?

Filed under , , & no comments & no trackbacks

Trackbacks

Trackback specific URI for this entry

No Trackbacks

Comments

No comments

Add a Comment & let me know what you think