select desc_description,
length(dbms_lob.substr(desc_description, 3500, 1)) len,
lengthb(dbms_lob.substr(desc_description, 3500, 1)) lenb,
convert(replace(translate(dbms_lob.substr(desc_description, 3500, 1), ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=`~!@#$%^&*()_+,./<>?;'':"[]\{}|',' '), ' ', ''),'us7ascii') bad_char_replaced,
rawtohex(convert(replace(translate(dbms_lob.substr(desc_description, 3500, 1), ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=`~!@#$%^&*()_+,./<>?;'':"[]\{}|',' '), ' ', ''),'us7ascii')) bad_char_replaced_hex ,
-------
convert(dbms_lob.substr(desc_description, 3500, 1),'us7ascii') converted
-------
from rc.rc_description
WHERE desc_description LIKE '%' || CHR(191) || '%' and
desc_cras_number = '20140096849';
The before text is : vehicle�s B pillar has ......
The After text is : vehiclei??s B pillar has ......
Can I get the above query to remove these ??? to apostrophe or double quotes ? or if that screws the data then jst use an empty space.
January 13, 2016 - 5:58 am UTC
Apologies - I misread your question to be *remove* the characters, rather than re-capture them.
If you are getting upside down question mark, there are 3 things that need to capable of handling the special characters they represent:
1) the database characterset
2) the client characterset
3) the client program/OS
For example, in SQL Plus on Windows (which runs in CMD prompt), no matter what you, some characters cannot be displayed, but CMD simply cant do it.
In the case above, where (I'm guessing) it was the common 'smart quotes' issue, and you want to preserve them - you need to ensure that your db and client NLS can handle it.
If you want to ditch them, then see my first answer.
If you want selectively replace them, then you need to a series of replace/translate as you have done, but using the code point number for smart quotes, eg
select ascii(' <smartquote> ') from dual;
and then
replace( string, chr(<number from above>), '')