怎样向Oracle的Blob字段中添加bmp图片

黑夜de星辰 2009-10-30 11:25:44
这段是我参考一个文档写的,添加不进去,请问问题在哪,急,在线等待,我是新手,资源分也不多,谢谢各位大哥大姐了。
char* procsql = "INSERT INTO T_SOC_CS_TOPO_GRAPH(GraphID,GraphName,GraphTypeID,Graph,Format) VALUES (:1,:2,:3,:4,:5)";
m_pstmt->setSQL(procsql);

Blob blob(m_pmysql);
blob.setEmpty();

m_pstmt->setInt(1,2);
m_pstmt->setString(2,"name");
m_pstmt->setInt(3,3);
m_pstmt->setBlob(4,blob);
m_pstmt->setString(5,"format");
m_pstmt->executeUpdate();
m_pmysql->commit();

string sqlQuery = "SELECT Graph FROM T_SOC_CS_TOPO_GRAPH where GraphID=1 FOR UPDATE";
m_pstmt->setSQL(sqlQuery);

ResultSet *rs = m_pstmt->executeQuery();
while(rs->next())
{

Blob blob=rs->getBlob(1);
unsigned int blobLen=blob.length();
unsigned int offset=1;

fstream infile;
infile.open("IAD.bmp",std::ios::binary | ios::in);
if (!infile.is_open())
{
return -1;
}
infile.seekp(0L ,ios::end);
int nlen = infile.tellp();
char* buf = new char[nlen + 1];
infile.seekp(0,ios::beg);
infile.read(buf, nlen);
infile.close();

Stream* strm=blob.getStream();

strm->writeBuffer(buf, nlen);


blob.closeStream (strm);
delete[] buf;
}
...全文
75 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
snoopy2002_007 2010-03-04
  • 打赏
  • 举报
回复
strm->writeLastBuffer("",0);
黑夜de星辰 2009-10-30
  • 打赏
  • 举报
回复
本人急用,在线等待各位大哥大姐指教,万分感谢

3,496

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 高级技术相关讨论专区
社区管理员
  • 高级技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧