Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 20 Feb 2007 @ 19:55:53 GMT


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


Subj:   Re: SUBSTR query
 
From:   Barry Hull

Try changing your update so that you first test to make sure that the columns are not equal and that they both contain a '-'. So, your update should look like this:

     UPDATE TAB1
     SET fn_diff = '10'
     WHERE index (mst_fn, '-') > 0
     and index (gst_fn, '-') > 0
     and mst_fn <> gst_fn
     and substr (mst_fn, 1, index (mst_fn, '-') -1) =
     substr (gst_fn,(index (gst_fn, '-')) +1)
     and substr (gst_fn, 1, index (gst_fn, '-') -1) =
     substr (mst_fn,(index (mst_fn, '-')) +1);

This way, you're validating that the string contains a '-' before using the position of the '-' in the SUBSTR command.



     
  <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