I need to replace the suffix "_TST" with "_TRN1" in a column .
For example , if the column contains the value xxx_tst I need to replace it to xxx_trn1.
How to do it?
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Thanks for your reply but I needed to replace only the appearances in the end of the word.
If the string "_TEST" (by mistake I wrote "_TST") appears in the middle of the word ,then the "replace" command will replace all the appearances.
I've just solved my problem as the following:
Code:
update table
set x=SUBSTR(x,1,length(x)-4)||'TRN1'
where substr(x,instr(x,'_',-1,1)+1,length(x)-instr(x,'_',-1,1))='TEST';
well... no literal on the middle of the string was bound to be changed by my script; look at the where clause, it filters out everything that does not have your desired literal at the end of the string.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Bookmarks