利用OCI,向BLOB字段插入数据的问题
问题是这样的:
oci编程:
向oracle数据库,拥有blob字段的数据插入数据时,用OCIBindByPos()函数,参数通过指定参数SQLT_BIN,可以向数据库blob字段插入数据,但是当value的位数比较大时会产生一个ora01426数值溢出问题
OCIBindByPos(stmthp, &bndhp, errhp, pos, (dvoid *)(value), (sb4)(valuesize),SQLT_BIN,(dvoid *) 0, (ub2 *)0, (ub2 *)0, (ub4) 0, (ub4 *) 0, (ub4) OCI_DEFAULT));
查了一下oci的文档,可以利用OCILobLocator来实现对blob的插入和获取。网上也找了不少例子。但是没有找到怎么通过OCILobLocator,来实现对非空blob的插入。
换句话说按照文档表述,没有实现成功
Binding LOB Locators
Either a single locator or an array of locators can be bound in a single bind call. In each case, the application must pass the address of a LOB locator and not the locator itself. For example, if an application has prepared a SQL statement like
INSERT INTO some_table VALUES (:one_lob)
where one_lob is a bind variable corresponding to a LOB column, and has made the following declaration:
OCILobLocator * one_lob;
Then the following sequence of steps would be used to bind the placeholder, and execute the statement
/* initialize single locator */
one_lob = OCIDescriptorAlloc(...OCI_DTYPE_LOB...);
...
/* pass the address of the locator */
OCIBindByName(...,(dvoid *) &one_lob,... SQLT_CLOB, ...);
OCIStmtExecute(...,1,...) /* 1 is the iters parameter */
网上还有oracle 提供的方法都是,向表中insert,空blob,然后再update。这种方法费时又费力。
有哪位达人,通过OCILobLocator,直接向blob字段插入数据的经历指点一下。