unable to store return value from execute statement in mysql -


using mysql, trying create stored proc retrieve maximum value of varchar column in given table. want increment value of column 1 , use store other fields. not want column int , auto increment.

the stored proc have delimiter $$

use gounicartdb$$  drop procedure if exists sp_getupdatedidfromtable$$  create procedure sp_getupdatedidfromtable( in tablename varchar(50), in columnname varchar(50), in incrementvalue int/*, out updatedid varchar(10)*/ ) begin  set @newid = "abc";  set @cmdstring = concat("select max(", columnname, ") ", tablename);  prepare stmt @cmdstring;  select @newid = execute stmt;  end$$  delimiter ; 

when compiling see no errors, when executing procedure following error occurs.

14:50:48    call sp_getupdatedidfromtable("user", "sno", 1) error code: 1054. unknown column 'execute' in 'field list'  0.000 sec 

please help.

you can replace in procedure

set @cmdstring = concat("select max(", columnname, ") @newid ", tablename); prepare stmt @cmdstring; execute stmt; select @newid; 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -