escaping - Escape string gets un-escaped in mysql concat function -
i have following sp:
create procedure sp_test ( text_data varchar(50) ) begin set @var_query = concat('select * sample_table col="',text_data,'"'); prepare stmt @var_query; execute stmt; deallocate prepare stmt; end;
i call sp call sp_test('screen size 4.3\"')
. error. if check value of @var_query variable, how looks.
+-------------------------------------------------------+ | @var_query | +-------------------------------------------------------+ | select sample_table col="screen size 4.3"" | +-------------------------------------------------------+
as can see escaped " getting un-escaped. if hit select statement directly escaped double-quotes, runs fine. means concat removing un-escaping escaped characters. how tackle issue?
this how have be:
set @var_query = select * sample_table col=?'; set @data = text_data; prepare stmt @var_query; execute stmt using @data; deallocate prepare stmt;
while
escape string gets un-escaped in mysql concat function
is correct , proper behavior.
Comments
Post a Comment