Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 22 Dec 2010 @ 15:46:28 GMT


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


Subj:   Re: How to pad zeros a decimal field.
 
From:   Geoffrey Rommel

  Is it possible to pad zeros to a variable and store it with zeroes in decimal field of tables. Consider the table1 having field tot_amount as decimal(5,0). The fields should have values like 00012,00123 etc  


In a word, no.

Numeric fields (integer, smallint, decimal, float, etc.) are stored in internal formats that are recognized by the processor as numeric. For instance, a smallint with a value of 12 will be stored as 0000000000001100 (big-endian). In hexadecimal, this would be represented as x'000C'. Note that in this example there are always exactly 16 bits, and the leading 12 bits are always 0''s. If you stored any other series of bits, it would be a different number.

When your program reads numeric values, it can display them in any way you like. For instance, the value above could appear as ' 12', '00012', or '***12', depending on the output format used.

When a column in a table has a default format (e.g. tot_amount decimal(5,0) format '99999'), it will only be used if the program selects the data in Field Mode. BTEQ does this, but most applications do not.



     
  <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