X-Received: by 10.224.41.145 with SMTP id o17mr27801389qae.3.1373531361907; Thu, 11 Jul 2013 01:29:21 -0700 (PDT) X-Received: by 10.49.71.173 with SMTP id w13mr1099873qeu.21.1373531361889; Thu, 11 Jul 2013 01:29:21 -0700 (PDT) Path: news.cambrium.nl!textnews.cambrium.nl!feeder2.cambriumusenet.nl!feed.tweaknews.nl!209.197.12.246.MISMATCH!nx02.iad01.newshosting.com!newshosting.com!216.196.98.146.MISMATCH!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!t19no1096615qam.0!news-out.google.com!f7ni1940qai.0!nntp.google.com!t19no1160591qam.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.databases.oracle.server Date: Thu, 11 Jul 2013 01:29:21 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=195.212.29.75; posting-account=QmaZSQoAAAAI-CJPxUT4uCrHrztSMCGs NNTP-Posting-Host: 195.212.29.75 References: <70f5affe-bf0a-467b-861d-74e3cedd37b9@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: UTL_RAW binary encoding From: neilsolent Injection-Date: Thu, 11 Jul 2013 08:29:21 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Lines: 157 Xref: news.cambrium.nl On Wednesday, 10 July 2013 01:00:21 UTC+1, ddf wrote: > On Tuesday, July 9, 2013 11:28:46 AM UTC-6, neilsolent wrote: >=20 > > Hi >=20 > >=20 >=20 > > I need to get data from a query of an integer column into a client, sto= red as an array of 8 bytes. In the course of getting Oracle to return the d= ata in the required format I am using the UTL_RAW functions, but I am strug= gling to understand what Oracle is returning. For example, can anyone expla= in these results? >=20 > >=20 >=20 > >=20 >=20 > >=20 >=20 > > SQL> select utl_raw.cast_from_number(5000) from dual; >=20 > >=20 >=20 > >=20 >=20 > >=20 >=20 > > UTL_RAW.CAST_FROM_NUMBER(5000) >=20 > >=20 >=20 > > -----------------------------------------------------------------------= --------- >=20 > >=20 >=20 > > C233 >=20 > >=20 >=20 > >=20 >=20 > >=20 >=20 > > SQL> select utl_raw.cast_from_number(131) from dual; >=20 > >=20 >=20 > >=20 >=20 > >=20 >=20 > > UTL_RAW.CAST_FROM_NUMBER(131) >=20 > >=20 >=20 > > -----------------------------------------------------------------------= --------- >=20 > >=20 >=20 > > C20220 >=20 > >=20 >=20 > >=20 >=20 > >=20 >=20 > > I am wanting a function that returns something like this: >=20 > >=20 >=20 > >=20 >=20 > >=20 >=20 > > 20 -> 14 >=20 > >=20 >=20 > > 131 -> 83 >=20 > >=20 >=20 > > 5000 -> 1388 >=20 > >=20 >=20 > >=20 >=20 > >=20 >=20 > > thanks >=20 >=20 >=20 > UTL_RAW returns HEX values of binary strings; it just happens that number= s generate hex strings startng with C (at least with all of the numbers I h= ave tried). These are not HEX numbers, but HEX strings, much different tha= n you would expect. What you want to do is use to_Char() to get the values= you expect: >=20 >=20 >=20 > SQL> select to_char(20, 'FMXXXX') from dual; >=20 >=20 >=20 > TO_CH >=20 > ----- >=20 > 14 >=20 >=20 >=20 > SQL> c/20/131 >=20 > 1* select to_char(131, 'FMXXXX') from dual >=20 > SQL> / >=20 >=20 >=20 > TO_CH >=20 > ----- >=20 > 83 >=20 >=20 >=20 > SQL> c/131/5000 >=20 > 1* select to_char(5000, 'FMXXXX') from dual >=20 > SQL> / >=20 >=20 >=20 > TO_CH >=20 > ----- >=20 > 1388 >=20 >=20 >=20 > SQL> >=20 >=20 >=20 >=20 >=20 > David Fitzjarrell Thanks David