从oracle db的LONG RAW中检索字节数组 [英] retrieving a byte array from a LONG RAW from oracle db

查看:117
本文介绍了从oracle db的LONG RAW中检索字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从oracle 11g数据库中的长原始字段中提取数据.但是,当我尝试时,我不断收到指定的演员表无效"的消息:

I am trying to pull data from a long raw field in an oracle 11g database. However I keep getting "specified cast is not valid" when I try:

cmd.InitialLONGFetchSize = 1000000;
cmd.AddRowid = true;
byte[] PicTempArray = new Byte[1024];
Oracle.DataAccess.Client.OracleDataReader Reader = cmd.ExecuteReader();

int i = 0;
while (Reader.Read())
{
   try
      {
      PicTempArray[i] = Reader.GetByte(0);
      }
   catch
      {
      }
   i++;
}

如果我做错了几件事,我不会感到惊讶.如果您没想到LONG RAW会保存一些图像数据.任何建议表示赞赏.

I wouldnt be surprised if I was doing a few things wrong. If you didnt guess the LONG RAW is holding some image data. Any advice is appreciated.

推荐答案

GetByte用于从数字列中检索单个字节.

GetByte is used to retrieve a single byte from a numeric column.

您要改为GetBytes.您可能还应该阅读文档,以获取"LONG and LONG RAW数据".

You want GetBytes instead. You should probably also read the documentation for "Obtaining LONG and LONG RAW Data".

(顺便说一句,我希望您真的没有一个空的catch块-如果您将camelCase用作本地变量名称,并且将花括号括起来,则代码会更加惯用trycatch块,就像while块一样.)

(As an aside, I hope you don't really have an empty catch block - and your code would be more idiomatic if you used camelCase for your local variable names, and outdented the braces for the try and catch blocks, as they are for the while block.)

这篇关于从oracle db的LONG RAW中检索字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆