Re: Is there a bitfield type field in oracle?
- From: malcolm <malcolmarnold@xxxxxxxxx>
- Date: Wed, 30 Jan 2008 09:58:22 -0800 (PST)
3) Is there a bitmap-kind of field that could hold one entry in a bit
of an integer type. Such things are available to software developers
who need to compress the data as much as possible.
I was going to write how this would not work, because although there
are bit manipulation functions in PL/SQL you would need a 365 bit
number (366 for leap years), and I thought this would be out of range.
But then I tried it, and it worked:
SQL> select bitand(power(2, 366), 1) from dual;
BITAND(POWER(2,366),1)
----------------------
1
Well, no exception anyway... But the answer is wrong. It should be
0. Weird. I chalk this up to a floating point inaccuracy.
Seems to silently give the wrong answer at 2^63. I'm using 64 bit
Oracle.
SQL> select bitand(power(2, 63), 1) from dual;
BITAND(POWER(2,63),1)
---------------------
1
SQL> select bitand(power(2, 62), 1) from dual;
BITAND(POWER(2,62),1)
---------------------
0
I think that's pretty crap. It should throw an overflow exception...
.
- References:
- Is there a bitfield type field in oracle?
- From: dean
- Re: Is there a bitfield type field in oracle?
- From: malcolm
- Is there a bitfield type field in oracle?
- Prev by Date: Re: Is there a bitfield type field in oracle?
- Next by Date: Re: Is there a bitfield type field in oracle?
- Previous by thread: Re: Is there a bitfield type field in oracle?
- Next by thread: Re: Is there a bitfield type field in oracle?
- Index(es):
Relevant Pages
|