Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Escaping Issue

Status
Not open for further replies.

mlager

Programmer
Sep 1, 2006
74
US
I've got an application that has an embedded insert statement that I do not have access to edit. It hits the MySQL 5.0 server like this:

INSERT INTO TABLE (PATH) VALUES ('D:\Reports\')

MySQL is complaining about this, because it looks like the slashes are being treated as escape characters. Is there a work around for this to make this statement work, it's the only way I can get this application to write to the MySQL database. It was written to work with MSSQL and this appears to be the one and only issue. Ideally, the application would send the INSERT statement like this:

INSERT INTO TABLE (PATH) VALUES ('D:\\Reports\\')

Any advice would be appreciated.
 
That is strange. MS SQL Server does not like it any better than MySQL, as far as I know.

You r question is a bit difficult to answer without knowing what you CAN influence. The query as you have given it is plain wrong in MySQL. Even if you run the server in ANSI mode, backslashes are still seen as escape characters.

If the last backslash can be omitted, that may solve the issue. \r is a carriage return, but that is case sensitive. The last backslash escapes the trailing quote, so the real error is an unterminated string and a missing closing parenthesis. So omitting the last backslash would make the statement succeed, with the possible drawback that the path is set to [CR]eports if you spell it with a lower case R. That could be solved by choosing another location. Escape sequences are:

\0 (NUL byte)
\'
\"
\b backspace
\n newline
\r carriage return
\t tab
\Z CTRL+Z (end-of-file on Windows)
\%
\_

How do you connect to the server? If you do this through an ODBC driver, that driver may have some options.


Good luck!


+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top