|
Home > Archive > SQL Anywhere database > July 2005 > Escapes off question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Escapes off question
|
|
|
| Adaptive Server Anywhere 9.0.2.3044
When I individually run these statements:
LOAD TABLE KID_initial_import FROM
'\\k2\distribute\tes
ting\Dave\Data\expor
t\data.txt' ESCAPES OFF
LOAD TABLE KID_initial_import FROM
'\\\\k2\distribute\t
esting\Dave\Data\exp
ort\data.txt' ESCAPES OFF
The first statement returns with:
Cannot access file '\k2\distribute\test
ing\Dave\Data\export
\data.txt' -- No
such file or directory
The second statement executes in 0.982 seconds with no errors
I figure I'm misunderstanding something. I expected ESCAPES OFF to cause
the engine to accept both backslashes as backslashes when I run the first
statement above. Am I wrong, or is this a bug?
Thanks for your help
| |
| Greg Fenton 2005-07-02, 3:25 am |
| Jim wrote:
> I figure I'm misunderstanding something. I expected ESCAPES OFF to cause
> the engine to accept both backslashes as backslashes when I run the first
> statement above. Am I wrong, or is this a bug?
No, the ESCAPES OFF clause relates to how the server handles the *data*
being loaded, not the arguments to the statement. By the time the
server is parsing the ESCAPES OFF clause, the path being passed will
have already been parsed (so '\' becomes '' and '\\server\share'
becomes '\servershare')
Personally I use forward slashes for all my path arguments:
'//server/share'
(yes, this works on the silly platforms that use backslashes to separate
file path elements).
greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/
| |
| Breck Carter [TeamSybase] 2005-07-04, 1:23 pm |
| On 1 Jul 2005 20:17:26 -0700, Greg Fenton
<greg. fenton_NOSPAM_@ianyw
here.com> wrote:
>'\\server\share' becomes '\servershare'
It's not *quite* that bad, but your point is made :)
Breck Grinning Running And Ducking
--
SQL Anywhere Studio 9 Developer's Guide
Buy the book: http://www.amazon.com/exec/obidos/A...7/risingroad-20
bcarter@risingroad.com
RisingRoad SQL Anywhere and MobiLink Professional Services
www.risingroad.com
| |
|
| So is there a way to turn this behavior off? Or to change the escape
character that the parser uses?
Even if a user of our product enters this into a textbox:
\\\\k2\distribute\te
sting\Dave\Data\expo
rt\data.txt
....when I save it to the database, it gets saved as:
\\k2\distribute\test
ing\Dave\Data\export
\data.txt
....that's OK for the first save. But that's how it gets loaded into a
textbox the next time I access it from a database.
So if I load it into a text box, and the user saves it again, it gets saved
like this:
\k2\distribute\testi
ng\Dave\Data\export\
data.txt
Now it's not correct.
For the most part we're going to be using backslashes as backslashes. I'd
like backslash escaping to be the exception rather than the rule. Anything
I can do? Right now, I'm just replacing all \\ with \ . And if there's a
\n in the path, I guess I need to replace it with \\n.
thanks
Jim
"Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> wrote in message
news:42c60746$1@foru
ms-1-dub...
> Jim wrote:
cause[color=darkred]
first[color=darkred]
>
> No, the ESCAPES OFF clause relates to how the server handles the *data*
> being loaded, not the arguments to the statement. By the time the
> server is parsing the ESCAPES OFF clause, the path being passed will
> have already been parsed (so '\' becomes '' and '\\server\share'
> becomes '\servershare')
>
> Personally I use forward slashes for all my path arguments:
>
> '//server/share'
>
> (yes, this works on the silly platforms that use backslashes to separate
> file path elements).
>
> greg.fenton
> --
> Greg Fenton
> Consultant, Solution Services, iAnywhere Solutions
> --------
> Visit the iAnywhere Solutions Developer Community
> Whitepapers, TechDocs, Downloads
> http://www.ianywhere.com/developer/
| |
| Breck Carter [TeamSybase] 2005-07-06, 11:23 am |
| The Help says "do not use this", and it shows the wrong default, but
if you are brave:
SET TEMPORARY OPTION ESCAPE_CHARACTER = 'OFF';
--SET TEMPORARY OPTION ESCAPE_CHARACTER = 'ON';
BEGIN
DECLARE @x VARCHAR ( 100 );
SET @x = '\\k2\distribute\tes
ting\Dave\Data\expor
t\data.txt';
SELECT @x;
END;
Breck
On 6 Jul 2005 08:27:41 -0700, "Jim" <jimsjbox@yahoo.com> wrote:
>So is there a way to turn this behavior off? Or to change the escape
>character that the parser uses?
>
>Even if a user of our product enters this into a textbox:
>
> \\\\k2\distribute\te
sting\Dave\Data\expo
rt\data.txt
>
>...when I save it to the database, it gets saved as:
>
> \\k2\distribute\test
ing\Dave\Data\export
\data.txt
>
>...that's OK for the first save. But that's how it gets loaded into a
>textbox the next time I access it from a database.
>
>So if I load it into a text box, and the user saves it again, it gets saved
>like this:
>
> \k2\distribute\testi
ng\Dave\Data\export\
data.txt
>
>Now it's not correct.
>
>For the most part we're going to be using backslashes as backslashes. I'd
>like backslash escaping to be the exception rather than the rule. Anything
>I can do? Right now, I'm just replacing all \\ with \ . And if there's a
>\n in the path, I guess I need to replace it with \\n.
>
>thanks
>Jim
>
>
>"Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> wrote in message
> news:42c60746$1@foru
ms-1-dub...
>cause
>first
>
--
SQL Anywhere Studio 9 Developer's Guide
Buy the book: http://www.amazon.com/exec/obidos/A...7/risingroad-20
bcarter@risingroad.com
RisingRoad SQL Anywhere and MobiLink Professional Services
www.risingroad.com
| |
| Erik Anderson 2005-07-06, 1:23 pm |
| Umm, if people are entering paths into a client application and it does
this, then there is a problem with the client application. Any time that
someone enters something that effectively gets inserted into an SQL
statement as a string it needs to be properly escaped by the application
when it is passed to the engine. What happens if someone includes a single
quote (') as part of the filename?
"Jim" <jimsjbox@yahoo.com> wrote in message news:42cbf869$1@foru
ms-2-dub...
> So is there a way to turn this behavior off? Or to change the escape
> character that the parser uses?
>
> Even if a user of our product enters this into a textbox:
>
> \\\\k2\distribute\te
sting\Dave\Data\expo
rt\data.txt
>
> ...when I save it to the database, it gets saved as:
>
> \\k2\distribute\test
ing\Dave\Data\export
\data.txt
>
> ...that's OK for the first save. But that's how it gets loaded into a
> textbox the next time I access it from a database.
>
> So if I load it into a text box, and the user saves it again, it gets
> saved
> like this:
>
> \k2\distribute\testi
ng\Dave\Data\export\
data.txt
>
> Now it's not correct.
>
> For the most part we're going to be using backslashes as backslashes. I'd
> like backslash escaping to be the exception rather than the rule.
> Anything
> I can do? Right now, I'm just replacing all \\ with \ . And if there's a
> \n in the path, I guess I need to replace it with \\n.
>
> thanks
> Jim
>
>
> "Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> wrote in message
> news:42c60746$1@foru
ms-1-dub...
> cause
> first
>
>
| |
|
| > What happens if someone includes a single
> quote (') as part of the filename?
Good point. I'll need to take care of single quotes. There are probably
others as well.
Thanks, Erik.
"Erik Anderson" < erikba@teamworkgroup
.com> wrote in message
news:42cc11df@forums
-2-dub...
> Umm, if people are entering paths into a client application and it does
> this, then there is a problem with the client application. Any time that
> someone enters something that effectively gets inserted into an SQL
> statement as a string it needs to be properly escaped by the application
> when it is passed to the engine. What happens if someone includes a
single
> quote (') as part of the filename?
>
> "Jim" <jimsjbox@yahoo.com> wrote in message
news:42cbf869$1@foru
ms-2-dub...
I'd[color=darkred]
a[color=darkred]
separate[color=darkr
ed]
>
>
| |
| John Smirnios 2005-07-11, 9:23 am |
| Insert your data via a hostvar rather than an inline text constant and
your data won't be subjected to escape/quote interpretation.
ASA 9.0.1 and later allow the filename in a LOAD statement to be a
variable too & that will allow you to get around escape/quote
interpretation when you invoke the LOAD statement.
-john.
--
John Smirnios
Senior Software Developer
iAnywhere Solutions Engineering
Whitepapers, TechDocs, bug fixes are all available through the iAnywhere
Developer Community at http://www.ianywhere.com/developer
Jim wrote:
>
>
> Good point. I'll need to take care of single quotes. There are probably
> others as well.
> Thanks, Erik.
>
> "Erik Anderson" < erikba@teamworkgroup
.com> wrote in message
> news:42cc11df@forums
-2-dub...
>
>
> single
>
>
> news:42cbf869$1@foru
ms-2-dub...
>
>
> I'd
>
>
> a
>
>
> separate
>
>
>
|
|
|
|
|