//批量写入BLOB内容, bloblist是表单数组结构, ncount是写入的图片数, blob为locator数组
bool arr_stream_write_blob(BLOBPIC **bloblist, sb4 ncount, OCILobLocator **blob)
{
ub4 array_iter = ncount; //写入图片数
ub4 *bufp[MAXPICNUM]; //写入缓冲区 oraub8 bufl[MAXPICNUM]; //写入缓冲区的大小
oraub8 byte_amtp[MAXPICNUM]; //每张图片的大小
oraub8 offset[MAXPICNUM];
sword st;
int i,j;
int piece_count; //片数
oraub8 lastpiecelen[MAXPICNUM]; //剩下的最后一片的大小
for(i = 0; i < MAXPICNUM; i++)
{
bufp[i] = NULL;
}

//初始化参数
for(i = 0; i < ncount; i++)
{
bufp[i] = (ub4)malloc(sizeof(ub4)*MAXBUFLEN);
byte_amtp[i] = 0; //写到LAST PIECE

offset[i] = 1;  if(bloblist[i]->flenth < MAXBUFLEN)
bufl[i] = bloblist[i]->flenth;
else
{
bufl[i] = MAXBUFLEN;
lastpiecelen[i] = bloblist[i]->flenth % MAXBUFLEN; //最后一片大小
}
}

//开始写入
for(i = 0; i < ncount; i++)
{
fseek(bloblist[i]->fp, 0, 0); //文件指针指向头 piece_count = bloblist[i]->flenth / MAXBUFLEN; //得到片数 /*
if(0 == piece_count)
{
fread(bufp[i], bufl, 1, bloblist[i]->fp); //从流中读第一段bufl长的数据到bufp
}*/

fread(bufp[i], bufl[i], 1, bloblist[i]->fp); //从流中读第一段bufl长的数据到bufp


if(bloblist[i]->flenth < MAXBUFLEN)
piece_count = 1; //写入第一片
st = OCILobArrayWrite(svchp, errhp, &array_iter, blob, byte_amtp, 0, offset, bufp, bufl, OCI_FIRST_PIECE, NULL, NULL, 0, SQLCS_IMPLICIT);

if( st == OCI_SUCCESS || st == OCI_NEED_DATA)
{
//写入中间的几片
for(j = 2; j < piece_count; j++)
{
assert(fread(bufp[i], bufl[i], 1, bloblist[i]->fp)); //读入接下来的几块 st = OCILobArrayWrite(svchp, errhp, &array_iter, blob, byte_amtp, 0, offset, bufp, bufl, OCI_NEXT_PIECE, NULL, NULL, 0, SQLCS_IMPLICIT);

}
}
else
{
printf("OCILobArrayWrite() error\n");
CheckErr(errhp, st);
return FALSE;
}



//写最后的一片
if(piece_count != 1)
{
assert(fread(bufp[i], lastpiecelen[i], 1, bloblist[i]->fp));
st = OCILobArrayWrite(svchp, errhp, &array_iter, blob, byte_amtp, 0, offset, bufp, lastpiecelen, OCI_LAST_PIECE, NULL, NULL, 0, SQLCS_IMPLICIT);
} } for(i = 0; i < ncount; i++)
{
free(bufp[i]);
bufp[i] = NULL;
}

return TRUE;
}
感觉插入完了。然后读取OCILobGetLenth()得到大小为0.。 郁闷了 哪位大侠指点下?