Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 29 Jul 1999 @ 11:40:49 GMT


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


Subj:   How to check the value of a bit in a BYTE field.
 
From:   Yves Mackels

Is there anybody who knows how can I check in SQL the value of the lowest bit of the third byte for the following BYTE field (VALEUR).

     CREATE MULTISET TABLE market.tst ,NO FALLBACK ,
          NO BEFORE JOURNAL,
          NO AFTER JOURNAL
          (
           VALEUR BYTE(5) NOT NULL DEFAULT '0000000000'XB)
     PRIMARY INDEX (INVOKED);

e.g : supposed the VALEUR field contains 3 BYTES : 000113. I need to know if the third BYTE (value : 13. Binary value : 1101) has its lowest bit set to 1. The answer is YES but how to write the right query?

I have tried :

     sel substring(T.VALEUR from 3 for 1) mod 2 AS Result
     from cismarket.tst T
     where Result = 0
     ;

That gives me the following error Code = 3643 Numeric operation on BYTE data is illegal.

Till now, I have not found a solution because you can do nothing with a BYTE field. Here is what the NCR documentation explains about byte conversion :

Byte Conversion
The form for byte conversion is: If the length specified by byte data definition is less than the length of byte expression or byte string, bytes beyond the specified length are truncated.

If byte data definition is fixed-length and the length is greater than that of byte expression, bytes of value binary zero are appended as required.

For byte data, the Teradata DBS allows conversions only to an identical type (byte to byte). Byte data cannot be converted to numeric, graphic, or character data.

If CAST is used and non-zero bytes are truncated, an error is reported

Maybe someone think about a solution......

PS: Let me know If you don't understand my question


Mackels Yves
DBA Teradata @ Belgacom



     
  <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