Does Db2 support bit operator's (or, and, xor) ?
If yes - how - I didn't find any reference in documentation.
(if not - I'll have to create udf )
Thanks in advance
Dmitriy Lyakh
Sent via Deja.com http://www.deja.com/
Before you buy.
Cheers,
-- Bill
I don't see any connections between integer types bit operations and
for bit data clause
(only if i need bit operations on character columns)
It's a pity that DB2 doesn't support bit operations
Thanks
Dmitriy Lyakh
In article <385D8C2E...@home.com>,
I agree - however it is probably not high on the priority list since
a library of functions and distinct types doing this can be easily written
by any one who needs it (or wants to sell it :-)
Bill pointed out FOR BIT DATA likely because it avoids codepage
conversions when you bind it out... The vector isn't much use when it's
mangled
E.g. a 32 bit vector would be
CREATE DISTINCT TYPE "BOOL" AS CHAR(1) FOR BIT DATA WITH COMPARISONS;
CREATE DISTINCT TYPE "BIT32" AS CHAR(4) FOR BIT DATA WITH COMPARISONS;
CREATE FUNCTION "AND"(BIT32, BIT32) RETURNS BIT32 LANGUAGE C ....
CREATE FUNCTION "TSTBIT"(BIT32, INT) RETURNS BOOL LANGUAGE C ....
Cheers
Serge
Dmitriy,
You can create any function you like for DB2 with user-defined
functions, and use these directly in SQL. I have fairly minimal
experience of bit operations personally, but would have thought such
functions would be trivial to write in a language such as C++?
--
Jeremy Rickard
(To email, change "SPAM" to "jbdr" in address.)
I think it would be nice if db2 will extend not only udf, but list of
operators (like &,|)
Thanks
Dmitriy Lyakh
In article <385E4868...@ca.ibm.com>,
Serge Rielau <sri...@ca.ibm.com> wrote:
> Hi Dmitriy,
>
> I agree - however it is probably not high on the priority list since
> a library of functions and distinct types doing this can be easily
written
> by any one who needs it (or wants to sell it :-)
>
> Bill pointed out FOR BIT DATA likely because it avoids codepage
> conversions when you bind it out... The vector isn't much use when
it's
> mangled
>
> E.g. a 32 bit vector would be
>
> CREATE DISTINCT TYPE "BOOL" AS CHAR(1) FOR BIT DATA WITH COMPARISONS;
> CREATE DISTINCT TYPE "BIT32" AS CHAR(4) FOR BIT DATA WITH COMPARISONS;
> CREATE FUNCTION "AND"(BIT32, BIT32) RETURNS BIT32 LANGUAGE C ....
> CREATE FUNCTION "TSTBIT"(BIT32, INT) RETURNS BOOL LANGUAGE C ....
>
> Cheers
> Serge
>
> Dmitriy Lyakh wrote:
>
> > Hi
> >
> > I don't see any connections between integer types bit operations and
> > for bit data clause
> > (only if i need bit operations on character columns)
> >
> > It's a pity that DB2 doesn't support bit operations
> >
> > Thanks
> > Dmitriy Lyakh
> >
There is an indirect correlation. I don't know your app and/or
environment, so only you would know if it is important to you or not :)
Iff you are worried about having a portable known binary collating
sequence for your binary columns across code pages, aren't worried about
the code page conversion on bind out, and want the system to in general
treat the data as binary then it may be important to you ... else not.
Wrt to built-in bit operations, yes it would of course be nice it they
were built-in. But then again, they are easy to write using UDFs ... the
UDF infrastructure was put there for easy datatype/operator
extensibility of the system for things like this.