You are not logged in.
Glad to help you.
Feel free to ask any question here.
Thanks for your help.
Here is a workaround.
First add a context variable in your job(e.g. context.new1).
Then code in tJavaRow as below.
context.new1 = "INSERT INTO books (title) VALUES ('"+input_row.title.replace("'", "\\'")+"');";
Then type context.new1 in the query field of tMysqlRow.
I test it and it works fine.
I get "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'some name'" and it does not insert.
if used in a tMysqlRow fails I have tried it
Do you get any error? Or what result do you get?
I am not sure why the quotes display differently but they are the correct quotes.
"INSERT INTO books (title) VALUES ('L\'some name');" if used in a tMysqlRow fails I have tried it. "INSERT INTO books (title) VALUES ('L\\'some name');" with two \ works.
I only have one tJavaRow I need to use this because I do not know where in the string the ' will be.
If I add two \ using the code below and send the output to a tlog I can see that both are stripped off.
output_row.title = input_row.title.replace("'", "\\'");
If I add four then two get through but they do not get inserted to the db.
If you know why this is please let me know.
Why do you add a second \ in tJavaRow?
The following string is ok.
"INSERT INTO books (title) VALUES ('L\'some name');"
Besides, I notice that your quotation is different from the normal quotation ' '.
Yours is ``.
I have a tJavaRow connected to a tMysqlRow
I need to insert a string that contain a ‘ for esample L’some name. This needs to be escaped in the insert statment
INSERT INTO books (title) VALUES (‘L\’some name’);
However if I hard code this statement in the tMysqlRow I need to add a second \ as tMysqlRow removes the first
INSERT INTO books (title) VALUES (‘L\\’some name’);
This is ok but in my job I am using the tJavaRow to add the \\ before the ‘ because tJavaRow also removes the \ characters I have added two more \\
output_row.title = input_row.title.replace("'", "\\\\'");
This leaves \\ before the ‘ when its is sent to the tMysqlRow but this fails
Please let me know if you know why.