I have the following string in an Oracle 9i database:
A,B,C,
I need to replace all instances of ',' when it is the last item in the string. I have come up with the following statement but it deletes everything in the field not just the comma. Any suggestions?
UPDATE table SET column = REPLACE(SUBSTR(column, -1, 1), ',', '');
UPDATE mytable SET column = SUBSTR(column, 1, LENGTH(column) - 1) WHERE SUBSTR(column, -1, 1) = ','
worked for me. The others still blanked out the whole line instead of just the last ','. – PeresREPLACE
returns null - check my updated answer – OnehorseUPDATE table SET column = SUBSTR(column, 2) WHERE SUBSTR(column, 1, 1) = ',';
– Onehorse