tags:

views:

412

answers:

3

I'm using the DBMS_SQL package that returns the value '12345' as a value for a column name.

How do you trim the apostrophes out from the value so that it could be converted into a number?

+1  A: 

Something like the following should trim the apostrophes:

substr(columnName, 2, length(columnName) - 2)

(As an aside, it's a pretty odd DB with a column name that's an integer, isn't it?)

dave
Pretty odd design. Yes. Though it has its advantages.Anyways, nicely done. Works perfectly.
jonasespelita
+1  A: 

This will remove leading and trailing apostrophes from a value:

RTRIM(LTRIM(value,''''),'''')

or if you prefer:

RTRIM(LTRIM(value,chr(39)),chr(39))
Tony Andrews
A: 

you could just use the "REPLACE" function to replace all single-quotes in the string with NULLs.

eg . with quotes : select 'Hello,''World''' from dual

quotes removed: select replace('Hello,''World''','''',NULL) from dual

But, a columnname in Oracle cannot begin with a digit, so 12345 is invalid as a column-name anyway.

CMG