stl string parsing for DB query statement
-
I wanted to parse database query and replace any single quotes in any value to two single quotes. eg: problem query : insert into tbl (col1,col2,col3) values('correct','in'correct',''also incorrect'); expected query after parsing : insert into tbl (col1,col2,col3) values('correct','in''correct','''also incorrect'); can some one share code to accomplish the above using std::string or with some other STL class. Thanks in advance.
-
I wanted to parse database query and replace any single quotes in any value to two single quotes. eg: problem query : insert into tbl (col1,col2,col3) values('correct','in'correct',''also incorrect'); expected query after parsing : insert into tbl (col1,col2,col3) values('correct','in''correct','''also incorrect'); can some one share code to accomplish the above using std::string or with some other STL class. Thanks in advance.
xcavin wrote:
I wanted to parse database query and replace any single quotes in any value to two single quotes.
You need to write a
replace_all
function, see eg. http://groups.google.com/group/comp.lang.c++/browse_frm/thread/de56189adf9f6e72[^]