mysql - Can I use a String as a WHERE CLAUSE -


can me jsp problem. im trying update database using code similar this:

so, have on servlet:

string querycondition = "id = 1"; 

that passed stored procedure:

create      definer=`root`@`localhost`      procedure `storedprocedure_1`(querycondition text) begin     update users set name = 'john'     querycondition; end 

i thinking if possible because update fail.
if isn't possible can recommend how can such thing

you can use in stored procedure prepared statement.

example:

delimiter //  create    definer=root@localhost    procedure storedprocedure_1(querycondition text)  begin    set @query := concat( 'update users set name = \'john\' ',                         querycondition );    prepare stmt @query;   execute stmt;   drop prepare stmt; end; //  delimiter ; 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -