Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 02 Aug 2005 @ 15:03:53 GMT


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


Subj:   Re: Writing UDF for Numeric Datatypes
 
From:   Dieter Noeth

Alexander T wrote:

  Does anyone know the internal storage for Numeric Datatypes.  


SQL Reference
Data Types and Literals
Chapter 3: Decimal/Numeric Data Types
DECIMAL/NUMERIC Data Types

"Decimal numbers are scaled by the power of ten equal to the number of fractional digits. The number is stored as a two�s complement binary number in one, two, four, or eight bytes. The number of bytes used for a decimal value depends on the total number of digits in that value."


  I want to write a function which takes two numeric datatypes and returns the greater one or 0 according to a condition.  


  It should be able to support any numeric with variable precisions.  


  How will I will be able to do that ?  


AFAIK you'll have to write overloaded UDFs for different datatypes.


  Also I would like to write a to_char function which takes a numeric type and returns the result in varchar.  


  The cast function will return with a dot. I don't need that .  


  It should work exactly as the to_char function in oracle.  


  For eg :  


  If we have column with type NUMERIC (10, 5) and the actual value in the column is say 105  


  Then in Teradata will return in teradata as 105.00000 but i need the value as 105 itself.  


You can do a lot of to_char variations with a format:

     select trim(105.00000 (format 'Z(5)'))

Dieter



     
  <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