Tag Archives: escape characters

ORACLE: How to escape special characters

We often need to escape special characters while retrieving the rows. To do that there are two ways;

  1. Use “SET ESCAPE ‘{ESC CHAR}’
  2. End the select statement with ‘ESCAPE ‘{ESC CHAR}’

For example;

SELECT SL.SYSTEM_CODE, SL.SYSTEM_DESCRIPTION, SL.SYSTEM_PARTICULARS FROM SYSTEMS_LIBRARY SL WHERE SL.SYSTEM_CODE LIKE 'UOTE\_%' ESCAPE '\'

the above statement returns all the systems with system code like ‘UOTE_’. But i cannot use the underscore directly in the quotes. Therefore I want to escape it with \ and tell Oracle to treat it as escape character by typing “ESCAPE ‘\'” at the end of the select statement.