Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: IP Address arithmetics in Oracle?

Re: IP Address arithmetics in Oracle?

From: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Tue, 2 Mar 1999 21:00:44 -0000
Message-ID: <920409422.28099.1.nnrp-12.9e984b29@news.demon.co.uk>


I see you have the IP addresses as RAW() Have a look at the utl_raw package
($ORACLE_HOME/rdbms/admin/utlraw.sql

This has bit_and, bit_or, bit_xor functions which take 2 raws and return a raw. Since these are pure functions (pragma restricts_references) you can use them in SQL statements.

--
Jonathan Lewis
Yet another Oracle-related web site: www.jlcomp.demon.co.uk

I have a spelling chequer
It came with my pea sea
It plainly marques for my revue
Miss steaks eye cannot sea

I've run this poem threw it
I'm shore your pleased to no
Its letter perfect in it's weigh
My chequer tolled me so

Rodney Volz wrote in message <7bhglj$ma0$1_at_news.LF.net>...
>Hello,
>
>I have a table 'ipacc' looking like this:
>
> Name Null? Type
> ------------------------------- -------- ----
> CHUNK NUMBER(32)
> SRC RAW(4)
> DST RAW(4)
> PACKETS NUMBER(32)
> BYTES NUMBER(32)
>
>Each row represents an amount of data (PACKETS, BYTES) that was
>transmitted from ip address 'SRC' to address 'DST'.
>
>I'd like to be able to SELECT for all IP addresses that
>belong to a given subnet. An ip address "belongs to a subnet"
>if the following expression is true:
>
> ipadr & subnet_mask == subnet_number
>
>For example:
>
> 192.168.1.1 & 255.255.255.0 == 192.168.1.0
>
>A select statement like this one would be fine:
>
> SELECT * FROM ipacc WHERE src & netmask = network-number;
>
>This of course won't work since oracle doesn't seem to know
>about binary AND/OR/NOT constructs.
>
>Any way to accomplish this? What would be the closest possible
>solution? What it boils down to is basically the question
>for binary arithmetic in Oracle.
>
>Regards,
>-Rodney Volz
>
Received on Tue Mar 02 1999 - 15:00:44 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US