autogenerated sql code: single backslash as an escape character is failing autogenerated sql code: single backslash as an escape character is failing oracle oracle

autogenerated sql code: single backslash as an escape character is failing


Not familiar with Linq but I'm a bit confused about where you're executing the query - are you just pasting the generated code into SQL*Plus running against two databases, where that behaviour can at least be explained?

If you are doing it in SQL*Plus, do a show escape in each environment; I suspect 9i will report escape "\" (hex 5c) while the 10g will report escape off. This might indicate that escape handling has previously been set up in the 9i instance but not in the (presumably more recent) 10g one.

If any of this has turned out to be relevant so far, try doing set escape \ in the 10g session and try the \\ version again. And in 9i try doing escape off and try the single-\ version there. Both should now work.

Assuming you're still with me, the next question is why 9i has that setting; there's probably a login.sql or glogin.sql file that's setting it automatically. You might be able to get that removed, as long as it won't affect anything else, to allow the generated code to run unaltered.

I don't think any of that will be relevant if you're going to be executing the code some other way; not sure if you're just testing and debugging the generated code in SQL*Plus and will eventually execute it elsewhere (lack of knowledge of Linq again), in which case this may be a transitory problem anyway.

I'm also not sure what you're actually escaping anyway...


Try:

  SELECT * FROM TABLENAME   WHERE COLUMNNAME LIKE '\%' ESCAPE '\';

Generally ESCAPE symbol in LIKE used for allow search symbols '%' and '_'


you could avoid the backslash issue altogether. Try using the curly braces around the escaped characters instead.

http://download.oracle.com/docs/cd/B10500_01/text.920/a96518/cqspcl.htm