Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 17 Jul 2002 @ 13:59:15 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Teradata String Replace within a string Function
 
From:   Geoffrey Rommel

  I have a string where I need to replace all the occurrences of a string with another string.  


  So CUST-ACCT-I needs to become CUST_ACCT_I  


  Is there a Teradata function to do this??  



Alas, no. When V2R5 is available, you will be able to define your own functions to do stuff like this. Since this kind of task is needed so often, however, I think the TRANSLATE function should be extended to allow translation from any set of characters to any other.

In the meantime, if the list of strings to be converted isn't too big, you could convert them with a join.

create table string_conversions
(old_string varchar(50),
new_string varchar(50) ) ...;
insert string_conversions ('CUST-ACCT-I', 'CUST_ACCT_I'); /*... and so on */

select ... b.new_string ...
from wherever a, string_conversions b
where a.old_string = b.old_string ...;


You get the idea, I'm sure.



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 27 Dec 2016