Not to rain on the parade Sonty but I think that he was hoping that
Oracle had some builtins to do just that. There are some basic bit
twiddling stuff in utl_raw (I think that is the package... you would
have to check) and parsing those hex values out would be pretty
straightforward. I have wracked my brain though to find a hex to
binary format converter and dont know of one in PL/SQL. Someone else
might ...David you out there?

Sonty is right though, it is pretty simple to write a quick function
to convert hex to a bitstring. you can do a simpleminded version
(usually my choice with low data volumes) with merely a loop and a
case statement. you could then either actually count the 1's or you
could remove the 0's and just check the length of the resulting
string. Not sure which would be faster.

for instance something like

select length(replace(hextobitstring(replace(vlanportislvlansallowed,'
',''),'0','') from sometable

where you write hextobitstring() to do the conversion from hex to a
bitstring.

Hope this helps a little

Rob

On Jan 12, 2:00 am, sonty <saurabh.zen...@gmail.com> wrote:
> Write a function which will convert the string and then will count the
> number of ones and return the sum....
>
> Sonty
>
> On Jan 6, 2:01 pm, Rem-8 <lukasz.r...@gmail.com> wrote:
>
>
>
> > Hello all oracle masters :)
>
> > I got a dillema. In an SNMP object called vlanportislvlansallowed
> > there's a VARCHAR2 (128) value of hex digits representation of all
> > Vlans on a network router/switch. Basically this means there could be
> > 1024 vlans. The output of SNMP in Oracle can be like this:
>
> > 00F8 0082 0000 0000 0000 0006 0004 0001 0080 0068 0033 00D1 0019 0050
> > 0038 0068 0050 0034 005D 00C6 0001 00E0 0010 0090 001C 0080.........
> > etc. up to 128 bytes long.
>
> > Now the clue is to convert this whole hex values into binary ones and
> > count all 1's and return the sum of whole line. I really don't know
> > why oracle puts 00 before each hex...- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Oracle PL/SQL" group.
To post to this group, send email to Oracle-PLSQL@googlegroups.com
To unsubscribe from this group, send email to
oracle-plsql-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/Oracle-PLSQL?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to