How to anticipate and avoid a single quote "in oracle
2 answers
The best way is to use quoting a string literal . Syntax q'[...]'
where the characters "[" and "]" can be any of the following, if they do not already appear on the string.
- []
- {}
- ()
- <>
You don't have to worry about single quotes inside a string.
Suppose the column value is aaa'gh
So, you can just write SQL as
SELECT q'[aaa'gh]' FROM DUAL;
This saves a lot of time for developers. Gone are the days when we (the developers) used to validate dynamic sql using dbms_output in the development db to make sure everything was in place before going into production.
+13
source to share