Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 14 Sep 2004 @ 17:48:42 GMT


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


Subj:   Re: UDF's without using C
 
From:   Michael Larkins

Hi All:

I am teaching an SQL class right now, so I am doing this on a break and didn't test the syntax. However, the logic is such that the last character comes back first and the first character comes back last using substring, column length and concatenation. It should be plenty to get anyone started coding the reversal via SQL.

It works because Terdata allows a negative starting location. Again, I have not tested this particular query, but I have used the same concept often. In other words, non-criticism for a syntax error would be appreciated since I have less than 10 minutes in this break to build it and prepare for the next session. :)

     sel name   /*  varchar(10)   */
         ,substring(name from char(name) for 1)||
         substring(name from char(name)-1 for 1)||
         substring(name from char(name)-2 for 1)||
         substring(name from char(name)-3 for 1)||
         substring(name from char(name)-4 for 1)||
         substring(name from char(name)-5 for 1)||
         substring(name from char(name)-6 for 1)||
         substring(name from char(name)-7 for 1)||
         substring(name from char(name)-8 for 1)||
         substring(name from char(name)-9 for 1)
     from name_table;

Regards,

Michael Larkins
Certified Teradata Master
Certified Teradata SQL Instructor



     
  <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