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

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -