I have a table with a column of data type LONG RAW
. How do I determine the size (in bytes) of the data in this column?
If I call the LENGTH
function on it, it raises ORA-00932: inconsistent datatypes: expected NUMBER got LONG BINARY
.
Just in case you think it: UTL_RAW.LENGTH
raises ORA-00997: illegal use of LONG datatype
:)
(Yes, I know LONG RAW
is deprecated - the question came up due to some old software that might require it)
As long as the data in the column does not exceed 16,383 bytes, you can solve this with a PL/SQL function, e.g.
Unfortunately, a LONG RAW can hold up to 2GB...
I don't think it's possible to manipulate LONG RAWs longer than 32k in PLSQL. Here is a java procedure that returns the length of a LONG RAW.
First, the setup:
The java class (my java is a bit rusty):
Let's call it:
I've tested the function with larger than 32k fields and it seems to work.
One dirty trick, which might help if you're playing with a small test database: copy all data in a table with a
BLOB
instead of aLONG RAW
.