We recently fixed an issue with the character encoding being read incorrectly into our system from the text files by making sure the file is UTF-8 and the Java code opens these files in UTF-8 encoding.
However, we had ended up adding a lot of records across the entire database tables with incorrect characters being inserted i.e. °F was read as �F. So even though we have fixed this now, we need to clean up the database tables now to rectify this anomaly.
Can anyone please suggest me ways to achieve this?
I had a similar problem a while back. Luckily, the number of columns that it affected was limited to a small number, and those columns had the same name throughout the database.
I solved this by writing a script that does the following:
target columns
REGEXP_REPLACE
This used a healthy dose of dynamic SQL, pulling data from the
user_constraintsanduser_tab_columns, filtering on the specific column names I was targeting.Here’s a rough skeleton to get you started, I’ve just thrown it together quickly, so it isn’t tested. Also, if you have triggers to worry about, you’ll need to disable those too: