Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 23 Feb 2007 @ 10:09:52 GMT


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


Subj:   Re: Replacing a character
 
From:   Mohd Suhail

Hi,

The following code works absolutely fine for replaceing '-' with '_'. However u can only replace the first '-' with '_' with this piece of code.

To do it repeatedly u can form a procedure and call it recursively.

     select TRIM (
     CASE POSITION('-'  IN 'T-RAT')
     WHEN
             0
     THEN
             'T-RAT'
     ELSE
     SUBSTRING('T-RAT' FROM 1 FOR INDEX('T-RAT','-') - 1) || '_' ||
     SUBSTRING('T-RAT' FROM (INDEX('T-RAT','-')+1) FOR characters('T-RAT'))
     END
     )

Output:

     T_RAT

Hope i answered your question.



     
  <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: 15 Jun 2023