Miracle
Miracle

Reputation: 387

Oracle sql make strings inside single qoutes

What I wanted is to place every string inside single qoutes even if it is delimited by a dot something like this:

Input: Hi.Hello.World

Output: 'Hi'.'Hello'.'World'

Note: Inputs can be 2 or more words delimited by a dot

Upvotes: 0

Views: 25

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522191

You could try this:

SELECT '''' || REPLACE(string, '.', '''.''') || ''''
FROM yourTable

Demo

The idea here is we replace every dot . with dot in single quotes '.'. This covers all internal dots/quotes. Then, to handle the outside single quotes, we can concatenate them on both sides.

Upvotes: 3

Related Questions