PL/SQL UTL_RAW.CAST_TO_RAW problem reading HEX data field with utl_file

From: Luke <luke_airig_at_hotmail.com>
Date: Thu, 29 Apr 2010 16:42:54 -0700 (PDT)
Message-ID: <ac0eda4f-d234-4f58-ad38-ab58dd464ab0_at_a18g2000prd.googlegroups.com>



Hello,

[Quoted] [Quoted] Oracle 11.2.0.1.0 running on SunOS 5.10.

[Quoted] I am encountering a PL/SQL problem with UTL_RAW.CAST_TO_RAW and can use some help.

I am reading and processing an input file that is a mix of ascii and hex fields.

Here is a snippet of the processing for the hex field in question:

  w_input_line CHAR(187); -- space for the input record   raw_hex_field raw(2);

  1. UTL_FILE.GET_LINE(w_file_handle, w_input_line);
  2. raw_hex_field := UTL_RAW.CAST_TO_RAW (substr(w_input_line, 93, 2));

This works fine for hex values x'0009', x'000B' and x'FFFF' but has a problem with x'000A':

Here is some debugging output:

  dbms_output.put_line ('raw_hex_field: ' || '>' || raw_hex_field || '<' );

  raw_hex_field: >0009<
  raw_hex_field: >000B<
  raw_hex_field: >FFFF<
  raw_hex_field: >00<            <<<<<<<<<<<<<<<<<<<<<<<<<<<<< HUH?
where is my 0A?

This is what I would hope to see:

  SQL->exec dbms_output.put_line( '>' || utl_raw.cast_to_raw( chr(00) || chr(10) ) || '<');
>000A<

  PL/SQL procedure successfully completed.

Is it possibly interpreting x'0A' as a line feed?

Changing the input record format is not an option for us. Can anyone help to resolve this?

TIA Luke Received on Fri Apr 30 2010 - 01:42:54 CEST

Original text of this message