好贷网好贷款

mfc 插入oracle blob、clob字段

发布时间:2016-12-4 20:29:40 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"mfc 插入oracle blob、clob字段",主要涉及到mfc 插入oracle blob、clob字段方面的内容,对于mfc 插入oracle blob、clob字段感兴趣的同学可以参考一下。

参考网址:http://sourceforge.net/p/orclib/discussion/470800/thread/5a2f05f1 当我看到这篇文字的时候想死的心都有了,所以写下来作为以后的教训,而且是深刻的教训呀。 方法一: OCI_Statement* stmt = OCI_StatementCreate(conn); OCI_Lob * clob = OCI_LobCreate(conn, OCI_CLOB); OCI_Prepare(stmt, "UPDATE tbl_clob SET clob = :clob WHERE id = :id"); OCI_BindLob(stmt, ":clob", clob); OCI_BindInt(stmt, ":id", &id); OCI_LobWrite(clob, const_cast(data.c_str()), data.length()); OCI_Execute(stmt);   方法二: #include "ocilib.h" #define SIZE_BUF 512 int main(void) { OCI_Connection *cn; OCI_Statement *st; OCI_Resultset *rs; OCI_Lob *lob1, *lob2; char temp[SIZE_BUF+1]; int code, n; if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); st = OCI_StatementCreate(cn); OCI_ExecuteStmt(st, "select code, content from test_lob for update"); rs = OCI_GetResultset(st); while (OCI_FetchNext(rs)) { code = OCI_GetInt(rs, 1); lob1 = OCI_GetLob(rs, 2); lob2 = OCI_LobCreate(cn, OCI_CLOB); n = OCI_LobWrite(lob1, "Today, ", 7); OCI_LobSeek(lob1, n, OCI_SEEK_SET); n = OCI_LobWrite(lob2, "I'm going to the cinema !", 25); OCI_LobAppendLob(lob1, lob2); OCI_LobSeek(lob1, 0, OCI_SEEK_SET); n = OCI_LobRead(lob1, temp, SIZE_BUF); temp[n] = 0; printf("code: %i, action : %s\n", code, temp); OCI_LobFree(lob2); } printf("\n%d row(s) fetched\n", OCI_GetRowCount(rs)); OCI_Cleanup(); return EXIT_SUCCESS; }

上一篇:Freemarker 生成work文档图片
下一篇:Java中的String不再纠结

相关文章

相关评论