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: A bug on RAWTOHEX function

Re: A bug on RAWTOHEX function

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Sat, 27 Nov 1999 11:39:27 -0500
Message-ID: <q3204sochp6m0mvmf29lvfk3ok5eis6959@4ax.com>


A copy of this was sent to "fumi" <fumi_at_tpts5.seed.net.tw> (if that email address didn't require changing) On 27 Nov 1999 15:15:38 GMT, you wrote:

>
>Hi, gurus,
>I found a bug on RAWTOHEX function.
>The return value are different when it is executed in PL/SQL and SQL.
>See the following example: (on Oracle8i, WinNT4 SP5)
>
>SQL> declare
> 2 a varchar2(8);
> 3 begin
> 4 a := rawtohex('AB');
> 5 dbms_output.put_line(a);
> 6 select rawtohex('AB') into a from dual;
> 7 dbms_output.put_line(a);
> 8 end;
> 9 /
>AB
>4142
>

it has always been that way -- plsql is doing an implicit conversion of 'AB' into a RAW (treats 'AB' as a single byte equal to chr(171)). A Rawtohex on that returns the string 'AB'.

SQL is not doing that implicit conversion on the bind. 'AB' is 2 byte RAW already. By selecting the rawtohex of that -- you get 4142.

So -- plsql does the implicit conversion. SQL does not.

>PL/SQL procedure successfully completed.
>
>
>
>
>
>

--
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st  

Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Sat Nov 27 1999 - 10:39:27 CST

Original text of this message

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