>> Does any body have solution for performing bitwise on db2 such that
I can call it from function or stored proc <<
Why, yes, I'll take this one! How abusive should I be :)?
Your whole model of SQL and RDBMS is totally wrong. (Hey, that is
mild abuse from me; I'll try to do better the next time:))
SQL is a high level language; it is abstract and defined without
regard to PHYSICAL implementation. Bits and Bytes are the **lowest**
units of hardware-specific, physical implementation you can get. Are
you on a high-end or low-end machine? Does the machine have 8, 16,
32, 64, or 128 bit words? Twos complement or ones complement math?
Hey, the standards allow decimal machines,so bits do not exist at
all!! What about NULLs? To be a datatype, yhou have to have NULLs,
so what is a NULL bit? By definition a bit, is on or off and has no
NULL.
What does the implementation of the host languages do with bits? Did
you know that +1, 0 and -1 are used for BOOLEANs, but not
consistently? That means ALL the host languages - present, future and
not-yet-defined. Surely, no good programmer would ever write
non-portable code by getting to such a low level as bit fiddling!!
What some Newbies, who are still thinking in terms of 2GL and 3GL
programming or even punch cards, do is build a vector for a series of
"yes/no" status codes, failing to see the status as a single
attribute. Imagine you have six components for a loan approval, so
you allocate bits in your 2GL model of the world. You have 64 possible
vectors, but only 5 of them are valid (you cannot be rejected for
bankruptcy and have good credit). For your data integrity, you can:
1) Ignore the problem. This is actually what **most** newbies do. I
then come in and charge their employer (opps, I meant "former
employer") big bucks to do a data quality audit :)
2) Write elaborate CHECK() constraints with UDFs that cannot port and
that run like cold glue.
Now we add a 7-th condition to the vector -- which end does it go on?
Why? How did you get it in the right place on all the possible
hardware that it will ever use? Did all the code that references a
bit in a word by its position do it right after the change?
Programs are employed by the company longer than the people who wrote
them -- remember that little "Y2K" thing?
There are VERY good reasons that we have First Normal Form (1NF).
You need to sit down and think about how to design an encoding of the
data that is high level, general enough to expand, abstract and
portable. For example, is that loan approval a hierarchical code?
concatentation code? vector code? etc? Did you provide codes for
unknown, missing and N/A values? It is not easy to design such
things!!