问题
I want to retrieve long raw data from a column having data type long raw into a clob variable.
If I directly write insert statement , I am not able to insert into long raw column.
I have to use utl_raw.cast_to_raw(..) function for inserting text into long raw column. Can someone explain this issue?
Let me explain you the workflow for this
User enters formatted text in a rich editor control in Delphi and saves.
Data is saved in a long raw column.
User clicks on a button in Delphi and data should retrieve from the long raw column and display in the rich editor control.
So all we need is a SQL that passes the id and it should return the data form the long raw.
This works but the data is not readable as we get binary garbage data.
The table structure for this table will be like create table data(id integer ,data long raw);
I am using oracle 9i as database.
回答1:
The LONG and LONG RAW data types have been deprecated in favour of CLOB and BLOB since Oracle 8.0 (i.e almost fifteen years ago). The primary reason for this switch is that LONG columns are really hard to work with, and that goes double for LONG RAW.
As you have already discovered, there is a limit to what we can do in PL/SQL. That limit is 32K. Larger LONG RAW columns can only be handled in C.
Tom Kyte used to host a utility for unloading Long Raw columns to a flat file, which could then be loaded to modern LOB columns through SQL Loader. This utlity appears to be unavailable (it's not on the list of /~tkyte files on his blog).
However, Fangxin Lou has written a version of another Tom Kyte utility, which he's called ociuldr
and which apparently handles Long Raw. You can download the source from his web site. Find out more.
NB I have not tried ociuldr
for myself (I haven't come across a Long Raw since the last millennium), and I'm not vouchsafing it in any way whatsoever. But it seems to be the only solution the internet offers right now. So I suggest you try it, unless you have good OCI skills and can write your own implementation.
来源:https://stackoverflow.com/questions/8084021/retrieving-long-raw-data-into-clob-variable