Help - Search - Members - Calendar
Full Version: Escaping characters in SQL Statements
4peeps.com Forums > General Hardware/Software > Programmers Corner
Mephist
ok, ive searched around, and tried a few things.... in java the character is the escape character so i tried that.... didnt work... i tried / but that also didnt work...

another website said @ was an escape character so i tried @' but it didnt work....so how does one go about inserting a record such as 'I'm frustrated' without it thinking that i gave 'I' only and the rest being treated as illegal syntax? icon_confused.gif
Mephist
doesnt anyone know how?? i looked around and i think i can use the following ESCAPE format for SELECT statements:

SELECT * FROM table_name WHERE arbitrary_field = 'arbitrary field@'s contents' ESCAPE '@'

however it doesnt seem to work for INSERT statements... can anyone help me? please? :P i wonder if it has anything to do with the fact that im working on Microsoft Access as my database for this. icon_eek.gif
AceHigh
Will get back with you as I'm going to bed right now, but will have an answer.
ldonyo
Have you tried using the double quote ( " ) to delimit your string?
AceHigh
use a backslash, i.e SELECT * FROM dept WHERE dname LIKE '%_%' ESCAPE '';

The ESCAPE option identifies the backslash () as the escape character. In the pattern, the escape character precedes the underscore(_).
Mephist
hey ace, thanks for that, however it doesnt seemt to work for INSERT statements... either that or MS Access just bites..
AceHigh
Access bites!
Mephist
so ESCAPE works in INSERT statements on MySQL, Oracle, SQL Server etc? icon_confused.gif
AceHigh
Yes
Mandark
access is a good prototyping tool....

here is the Oracle manuals for future help....

http://otn.oracle.com/documentation/oracle9i.html
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.