Re: bit to byte conversion
Date: Mon, 31 May 1999 11:12:22 +0100
Message-ID: <37526086.3FF30CA1_at_nkk.net>
You might try something like:
create or replace procedure bit2byte (mybit_in in char) is
x number;
y number;
a varchar2(8);
b char;
begin
x := ascii(mybit_in);
for i in 1..8
loop
y := mod(x, 2);
if y = 1 then
x := x - y;
b := '1';
else
b := '0';
end if;
a := b || a;
dbms_output.put_line(b);
x := x / 2;
end loop;
dbms_output.put_line (a);
end bit2byte;
set serveroutput on
execute bit2byte('Ñ');
Venkat Narayanan schrieb:
> Hi. I am looking for a way to convert a one character byte data in Oracle to
> the independent bits represented by the value in the character data. That
> is, the one character data should become 8 character fields with each field
> having 0 or 1 depending upon the bit pattern of the source character data.
> Is there a way to do this in PL/SQL ? Please reply to
> venkat.narayanan_at_kdynamics.com
>
> Cheers
> Venkat
Received on Mon May 31 1999 - 12:12:22 CEST