eatSleepCode
eatSleepCode

Reputation: 4637

What is the best way to trim leading and trailing single quotes in pl_sql

I am getting a Varchar2 variable with leading and trailing single quotes but I want to remove these single quotes, I am doing it like

trim(BOTH '''' FROM lastname);

It is giving me right result but is it a right way or is there any other way to do that.

Thanks in advance.

Upvotes: 2

Views: 2589

Answers (1)

René Nyffenegger
René Nyffenegger

Reputation: 40499

I think you can't get any better than what you already proposed. So yes, this is the right way.

Using BOTH is not necessary as it is the default (as oppposed to the also valid leading and trailing specifiers). So, depending to your preferences (short vs clear) you might leave it out, so that your statement becomes

trim('''' from lastname)

Upvotes: 3

Related Questions