Pages

Saturday 22 October 2016

How to handle a single quote in Oracle SQL?

How do I insert a record in a column having varchar data type having single quote in it?

Example:

first name is ROBERT and last name is D'COSTA

Solution:

Use Double Quotes
SQL> SELECT 'D''COSTA' name FROM DUAL;

NAME
-------
D'COSTA
Alternatively use quoting method (oracle 10g+ )
SQL> SELECT q'$D'COSTA$' NAME FROM DUAL;

NAME
-------
D'COSTA

Code Review

 SOLID Principles S – Single Responsibility Principle There should never be more than one reason for a class to change. O – Open-Closed Prin...