on 2016 Mar 15 5:34 PM
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Four backslashes first and two between. That will retun '\\test\\temp\\filetest.txt' in the procedure.
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.
It may also depend on how you call the procedure. For example, if you're calling dbisql -c ... call myproc('\\\\\\\\test\\\\temp\\\\filetest.txt')
from a command shell, the command shell itself may use the same escaping. You may need to double the backslashes twice, i.e. 8 at the beginning and 4 as directory separators.
...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...
User | Count |
---|---|
68 | |
10 | |
10 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.