【问题标题】:Oracle Long Raw PictureOracle 长原始图片
【发布时间】:2013-12-11 10:57:04
【问题描述】:

我有一个名为 students 的表,并有一个名为 studentnumberstudentphoto(LONGRAW) 的列,我需要将此 longraw 导出为 jpeg。我该怎么做?
我到处搜索,但找不到任何解决方案。
我的代码:

Dim ImgWriter As New BinaryWriter(File.OpenWrite(outsideTxt.Text + "\" + flname))
            Dim ImgBlob(102400) As Byte
            Dim lBytesReturned As Long = 0, lStartIdx As Long = 0
            Dim buffersize As Integer
            buffersize = 4096
            lBytesReturned = x.GetBytes(0, lStartIdx, ImgBlob, 0, buffersize) ' The exception occurs here
            Do While (lBytesReturned = buffersize)
                ImgWriter.Write(ImgBlob)
                ImgWriter.Flush()
                lStartIdx = lStartIdx + buffersize
                lBytesReturned = x.GetBytes(0, lStartIdx, ImgBlob, 0, ImgBlob.Length)

                ImgWriter.Write(ImgBlob)
                ImgWriter.Flush()
                ImgWriter.Close()
            Loop

注意:名为 photo 的列总是返回为 null。 我在c#中试过还是一样。 我该如何解决这个问题?

【问题讨论】:

  • 嗨@Mustibh Upd 这个答案对解决您的问题有帮助吗?如果不是,请在您的问题中添加不成功的内容。当答案对您有帮助时,您是否可以通过单击旁边的空心绿色复选标记来接受它?

标签: vb.net oracle blob


【解决方案1】:

Long 原始数据类型已成为过去,它是一种普通的构造。一段时间以来,Long raw 是在 Oracle 中存储二进制文件的唯一方法。您可以使用 OCI 访问它,最好使用 Pro*C。但是使用 Pro*C 会引入 Oracle 特定的预编译器和 C。众所周知,预编译器很难升级版本。

我会推荐以下方法:

在 VB.Net 中使用 ODP.Net(如果尚未使用)并执行将 long raw 转换为现代 blob 的查询,例如:

select to_lob(studentphoto) the_photo
from   students
where  studentnumber=250370

然后像使用 varchar2 一样获取 the_photo 的结果。

如果您需要更多示例,请输入表格结构 (DDL)、带有一些简单照片的插入(可能只是原始字符串“a”)以及有关您问题中使用的驱动程序的信息。祝你好运!

【讨论】:

  • 很高兴听到这为您解决了问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-07
相关资源
最近更新 更多