I am trying to write a select query which should return the column value wrapped in single quote. Say the column (ABC) has
Values: 123
567
The query should return the
Output: '123'
'567'
I am trying to write a select query which should return the column value wrapped in single quote. Say the column (ABC) has
Values: 123
567
The query should return the
Output: '123'
'567'
While dealing with numerical data, you can simply concatenate. NULL values stay
NULL
. But for character data (or similar) that might need escaping, use proper functions.quote_nullable()
orquote_literal()
- depending on whether you have NULL values:Details for quoting:
I tend to escape the quote with another one, as in the standard SQL escape syntax:
When wrapping some output values, you'll have to concatenate with ||:
Maybe you'll find it clearer using the E syntax: