MySQL Forums
Forum List  »  Stored Procedures

Dynamic SQL problem in Store Procedure
Posted by: Mark Rouse
Date: July 13, 2012 06:55AM

I have the following code in a stored procedure:

set @s= concat('SELECT ID, replace(replace(field_a,''*'',''''),''\''',''\\'''')
FROM table where field_b = ',vVariable,'');

prepare stmt from @s;
execute stmt;
deallocate prepare stmt;

I'm getting syntax errors around the second replace. I want to find single quote characters in field_a and replace them were they occur with \'.

I think I've not got enough single quote marks but have tried many variations in the number of quote marks surrounding my find and replace patterns, but still get the syntax error.

Options: ReplyQuote


Subject
Views
Written By
Posted
Dynamic SQL problem in Store Procedure
2242
July 13, 2012 06:55AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.