Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 09 Sep 2004 @ 06:35:48 GMT


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


Subj:   Re: Converting HEX to ASCII
 
From:   Dieter Noeth

Dennis Calkins wrote:

  HASHBUCKET is only defined for Values < 65536 since it's purpose is to return the UPPER 2 bytes of the ROWHASH.  


  Teradata only support 65563 hashbuckets. Values > 65536 will be truncated and only return a Value which is MOD 65536.  



     /*** BYTE(4) --> Unsigned (DEC(18,0))/Signed (INT) numeric value ***/
     SELECT
        HASHBUCKET(b) * 65536. +
        HASHBUCKET(SUBSTR(b,3,2) (BYTE(4))) AS UnsignedValue,

        HASHBUCKET(b) * 65536. +
        HASHBUCKET(SUBSTR(b,3,2) (BYTE(4))) -
        (CASE WHEN HASHBUCKET(b (BYTE(4))) / 32768 = 0 THEN 0 ELSE 4294967296
     END) (INT) AS SignedValue,

        (HASHBUCKET(b) * 65536. +
         HASHBUCKET(SUBSTR(b,3,2) (BYTE(4))) -
         HASHBUCKET(b (BYTE(4))) / 32768 * 4294967296) (INT) AS SignedValue2
     FROM
        (SELECT '07D307D3'xb AS b) dt
     ;

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