Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: A bug on RAWTOHEX function

Re: A bug on RAWTOHEX function

From: Martin Haltmayer <Martin.Haltmayer_at_0800-einwahl.de>
Date: Sat, 27 Nov 1999 20:23:54 +0200
Message-ID: <384021BA.55C7FE9@0800-einwahl.de>


Hi Fumi,

compare to this:

set serveroutput on

declare

	b raw (1):= 'AB';
	a varchar2(8);
begin
	a := rawtohex(b);
	dbms_output.put_line(a);
	select rawtohex(b) into a from dual;
	dbms_output.put_line(a);

end;
/

It returns 'AB' and 'AB' just on Oracle8i on NT 4.0 SP 5.

The reason is in your constant 'AB' which is not a RAW but a VARCHAR2 and it is converted implicitly and differently.

Bottom line: Avoid implicit conversion.

Martin

fumi 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
>
> PL/SQL procedure successfully completed.
Received on Sat Nov 27 1999 - 12:23:54 CST

Original text of this message

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