1 Reply Latest reply: Jun 25, 2013 3:39 AM by Chrisjenkins-Oracle RSS

    How to do a bitwise operation on a specific column in timesten database

    3d0da302-2736-4bf6-ba69-f181cb5853d1

      Hi,

      I need to do a bitwise and (&) operation on a column data(whose datatype is NUMBER).

      If I do something like SELECT 1010 & COLUMN1 from TABLENAME;

      It will give error :"Operand data type 'NUMBER' invalid for operator 'BITAND' in expr "

       

      Can anyboday help me ?

       

      Thanks in advance

      Regards

      Aithal

        • 1. Re: How to do a bitwise operation on a specific column in timesten database
          Chrisjenkins-Oracle

          NUMBER is a floating point format. Bitwise operators apply only to INTEGER values. There are several ways around this...

           

          1.    If the column in the database actually only stores integral values then change its definition to NUMBER(n) (choose n) suitably.

           

          2.    Change the select statement to be SELECT 1010 & CAST(COLUMN1 AS TT_INTEGER) (or TT_BIGINT depending on the maximum value you might tore in the column)

           

          3.   Change the column to a native TimesTen integer type such as TT_INTEGER, TT_BIGINT etc. This will use less space and perform better.

           

          Columns should *only* be defined as NUMBER (with no precision or scale) if they truly need to have that flexibility. Always use an explicit precision (and scale where appropriate) as this saves memory and avoids this kind of issue. Better still, use TimesTen native integer types wherever possible. They use less memory and provide higher performance than all variants of NUMBER.

           

          Chris