Stored Procedure with ALTER TABLE
        Posted  
        
            by psayre23
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by psayre23
        
        
        
        Published on 2010-03-26T00:00:51Z
        Indexed on 
            2010/03/26
            0:03 UTC
        
        
        Read the original article
        Hit count: 349
        
mysql
|mysql-stored-procedure
I have a need to sync auto_increment fields between two tables in different databases on the same MySQL server. The hope was to create a stored procedure where the permissions of the admin would let the web user run ALTER TABLE [db1].[table] AUTO_INCREMENT = [num]; without giving it permissions (That just smells of SQL injection).
My problem is I'm receiving errors when creating the store procedure. Is this something that is not allowed by MySQL?
DROP PROCEDURE IF EXISTS sync_auto_increment;
CREATE PROCEDURE set_auto_increment (tableName VARCHAR(64), inc INT)
BEGIN
    ALTER TABLE tableName AUTO_INCREMENT = inc;
END;
© Stack Overflow or respective owner