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: fumi <fumi_at_tpts5.seed.net.tw>
Date: 29 Nov 1999 15:12:38 GMT
Message-ID: <81u556$9gd$1@news.seed.net.tw>

Thomas Kyte <tkyte_at_us.oracle.com> wrote in message news:q3204sochp6m0mvmf29lvfk3ok5eis6959_at_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.

Yeah, I see.
It's the issue of the implicit conversion. I should had known it. I'll inform my colleagues and document it in programming standard to avoid the pitfall. Thanks to Thomas and Martin. Received on Mon Nov 29 1999 - 09:12:38 CST

Original text of this message

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