I have a procedure where I have a UNC path as IN parameter. The IN paramater is handled as a varchar. I write '\\test\temp\filetest.txt'. But the path is not working in the procedure because all bakslash disappear except one? In the procedure, the path will be '\test\temp\filetest.txt'? Why, and how do I solve the problem? |
Backslashes are used to escape special characters (e.g. \n represents a newline character). When a backslash precedes a character (or character sequence) that is not a valid escaped character then the backslash is left alone. If you intend for a backslash to not be an escape sequence in a string you need to double up the backslash. You can read more about escape sequences in SQL strings in the documentation. HTH IN to the procedure is '\\test\temp\filetest.txt'. Four backslashes first and two between. That will retun '\test\temp\filetest.txt' in the procedure. So you mean that I should write '\\\test\\temp\\filetest.txt' IN to the procedure? Six backslashes first and four between.
(16 Mar '16, 03:23)
Rolle
Replies hidden
That's unusual, it should be used as '\\test\temp\filetest.txt' . Do you use EXECUTE IMMEDIATE within the procedure? - If so, note that this may mean you have to "double" the doubled backslashes again or use the WITH ESCAPES OFF clause, see the cited doc page.
(16 Mar '16, 03:35)
Volker Barth
It may also depend on how you call the procedure. For example, if you're calling
(16 Mar '16, 08:10)
Graeme Perrow
Replies hidden
1
...and sometimes you can get away with using a single forward slash to represent a single back slash in a SQL Anywhere string literal. The word "sonetimes" is a warning that sometimes you are NOT coding a SQL Anywhere string literal but a Windows command string literal so your results depend on the context. And watch out for Ba'al...
(16 Mar '16, 10:02)
Breck Carter
|