Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Converting character field containing hex to number
Try this...
CREATE OR REPLACE
FUNCTION hextodec (hexnum in char) RETURN number IS
x number;
digits number;
result number := 0;
current_digit char(1);
current_digit_dec number;
BEGIN
digits := length(hexnum);
for x in 1..digits loop
current_digit := SUBSTR(hexnum, x, 1);
if current_digit in ('A','B','C','D','E','F') then
current_digit_dec := ascii(current_digit) - ascii('A') + 10;
else
current_digit_dec := to_number(current_digit);
end if;
result := (result * 16) + current_digit_dec;
end loop;
return result;
END;
/
Steve
> -----Original Message-----
> From: Murray, Margaret [mailto:mamurray_at_husseyseating.com]
> Sent: Friday, October 20, 2000 12:45 PM
> To: Multiple recipients of list ORACLE-L
> Subject: Converting character field containing hex to number
>
>
> Hi All,
> I'm on 7.3.4 on NT (yes, but we're running Applications 10.7,
> that's why)
> and in the v$process table there's a column spid which
> appears to be the NT
> pid number in hex. How can I convert this from hex to a
> number? HEXTORAW
> won't work as this isn't raw.
>
> My ultimate goal is to be able to query v$process, get a
> process id number
> and use task manager to kill the renegade pid. This worked
> great on UNIX,
> but will it work on NT?
>
> Margaret Murray
> Hussey Seating
>
> Example:
> SQL> select addr, pid, spid, serial# from v$process;
>
> ADDR PID SPID SERIAL#
> -------- ------ --------- ---------
> 30827044 192 0022B 4
> 308272DC 193 00249 2
> 30827574 194 0025D 5
>
> SQL> desc v$process
> Name Null? Type
> ------------------------------- -------- ----
> ADDR RAW(4)
> PID NUMBER
> SPID VARCHAR2(9)
> USERNAME VARCHAR2(15)
> SERIAL# NUMBER
> TERMINAL VARCHAR2(16)
> PROGRAM VARCHAR2(64)
> BACKGROUND VARCHAR2(1)
> LATCHWAIT VARCHAR2(8)
> LATCHSPIN VARCHAR2(8)
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Murray, Margaret
> INET: mamurray_at_husseyseating.com
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
>
This e-mail is intended for the use of the addressee(s) only and may contain privileged, confidential, or proprietary information that is exempt from disclosure under law. If you are not the intended recipient, please do not read, copy, use or disclose the contents of this communication to others. Please notify the sender that you have received this e-mail in error by Received on Fri Oct 20 2000 - 12:05:04 CDT
![]() |
![]() |