Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bit operators in DB2 (6.1)

5 views
Skip to first unread message

Dmitriy Lyakh

unread,
Dec 19, 1999, 3:00:00 AM12/19/99
to
Hi

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.

O'Connell

unread,
Dec 20, 1999, 3:00:00 AM12/20/99
to

You need to use scalar UDF functions; look at defining your datatypes
for this purpose with the FOR BIT DATA clause (via the CREATE TABLE
statement).

Cheers,
-- Bill

Dmitriy Lyakh

unread,
Dec 20, 1999, 3:00:00 AM12/20/99
to
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

In article <385D8C2E...@home.com>,

Serge Rielau

unread,
Dec 20, 1999, 3:00:00 AM12/20/99
to
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

Jeremy Rickard

unread,
Dec 20, 1999, 3:00:00 AM12/20/99
to
In article <83l2d1$mlu$1...@nnrp1.deja.com>, Dmitriy Lyakh
<Dmitri...@epam.com> writes

>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

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.)

Dmitriy Lyakh

unread,
Dec 21, 1999, 3:00:00 AM12/21/99
to
Hi

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
> >

O'Connell

unread,
Dec 21, 1999, 3:00:00 AM12/21/99
to

Hi Dmitriy,

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.

0 new messages