Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Binary(cobol comp-3) data from Oracle
When assigning a RAW value to a character variable, Oracle implicitly invokes the RAWTOHEX function to convert the value to a hexadecimal representation.
e.g. in SQL*Plus, you'll find that the statement:
select HEXTORAW('F00F00') foo
from dual;
is equivalent to the statement:
select RAWTOHEX(HEXTORAW('F00F00')) foo from dual;
I suspect that your problem is that the RAW variable is being used as an argument of an assignment, of a function (e.g. substr), or of an operation (e.g. concatenation) where Oracle is expecting an expression of type CHAR or VARCHAR.
I don't know of an easy fix or a workaround to get the value out of Oracle in COMP-3 format. I think I would write out the file with the value as a character data (in cobol DISPLAY format) and then run the file through a utility (like syncsort) to re-format the file with the value as COMP-3.
You didn't mention the version of Oracle. There may be some newer features in Oracle 8.0 or 8.1 (of which I am not yet aware) that may address the problem.
BTW.. you also didn't mention the operating system, but on MVS (IBM system/390, VS COBOL II) COMP-3 is actually a "packed decimal" representation, COMP is a true "binary" representation.
"Michael Rothwell" <marothwell_at_yahoo.com> wrote in message
news:39247CE4.41C9B504_at_yahoo.com...
> I am in the middle of converting some old cobol code to PL/SQL
> packages. This is information that is being sent to an old
legacy
> system, so I need to duplicate the output of the old code. So
far, so
> good. The only problem I have is writing a file that contains
one field
> that is binary( COBOL comp-3 ). I can read the comp-3 field
using
> RAWTOHEX, but when I use HEXTORAW it just returns the value I
pass it.
>
> What do I need to do to get the data output in binary??
>
> Thanks for any input.
>
> Michael
>
>
Received on Thu May 18 2000 - 00:00:00 CDT