将长原始数据检索到 clob 变量中
我想从数据类型为 long raw 的列中检索长原始数据到 clob 变量中。
如果我直接编写插入语句,我无法插入长原始列。
我必须使用 utl_raw.cast_to_raw(..) 函数将文本插入长原始列。 有人可以解释这个问题吗?
让我向您解释一下此工作流程
用户在 Delphi 的富编辑器控件中输入格式化文本并保存。
数据保存在长原始列中。
用户单击 Delphi 中的按钮,数据应从长原始列中检索并显示在富编辑器控件中。
所以我们需要的只是一个传递 id 的 SQL,它应该返回 long raw 的数据。
这可行,但数据不可读,因为我们得到二进制垃圾数据。
该表的表结构如下 创建表数据(id整型,data long raw);
我使用 oracle 9i 作为数据库。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
自 Oracle 8.0(即大约十五年前)以来,LONG 和 LONG RAW 数据类型已被弃用,取而代之的是 CLOB 和 BLOB。这种切换的主要原因是 LONG 列确实很难使用,对于 LONG RAW 来说更是如此。
正如您已经发现的,我们在 PL/SQL 中能做的事情是有限的。该限制是 32K。较大的 LONG RAW 列只能在 C 中处理。Tom
Kyte 曾经托管一个实用程序,用于将 Long Raw 列卸载到平面文件,然后可以通过 SQL Loader 将其加载到现代 LOB 列。该实用程序似乎不可用(它不在他的博客上的 /~tkyte 文件列表中)。
然而,Fangxin Lou 编写了另一个 Tom Kyte 实用程序的一个版本,他将其称为 ociuldr,并且显然可以处理 Long Raw。您可以从他的网站下载源代码。 了解更多。
注意我自己还没有尝试过
ociuldr
(自上个千年以来我还没有遇到过Long Raw),而且我不会以任何方式保证它。但这似乎是目前互联网提供的唯一解决方案。所以我建议你尝试一下,除非你有良好的 OCI 技能并且可以编写自己的实现。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.