I am currently switching an application from using Pro*c to using OCILIB.
Everything works fine, except updating clobs.
When trying to update a clob, I always get an access violation in
oracommon9.dll trying to read address 0x45.
An example:
...//InitializingconnectionOCI_Statement*stmt=OCI_StatementCreate(conn);OCI_Prepare(stmt,"UPDATE tbl_clob SET clob = :clob WHERE id = :id");OCI_SetBindAllocation(stmt,OCI_BAM_INTERNAL);OCI_BindArrayOfLobs(stmt,":clob",NULL,OCI_CLOB,0);stringdata;//Containsapprox.4millioncharssize_tcharCount=data.length();size_tbyteCount=0;OCI_LobWrite2(static_cast<OCI_Lob*>(OCI_BindGetData(OCI_GetBind2(stmt,":clob"))),const_cast<char*>(data.c_str()),&charCount,&byteCount);...//Bind:idOCI_Execute(stmt);//AccessViolationduringthiscall
I am using OCILIB 3.9.2 on Oracle 9.2.0.8.
What am I doing wrong?
Regards,
Dries
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2011-09-26
The database layer am I migrating over from Pro*C is lot more dynamic than the
simple example I gave to demonstrate the problem. Adding the fact
OCI_BAM_INTERNAL and OCI_BindLob can not work together (gives an ORA-24813; it
looks like the OCILobLocator is never assigned to buf.data of the OCI_Bind), I
will use the array interface as you proposed.
Thanks for your help.
As I want use OCI_BAM_INTERNAL f
As I am using OCI_BAM_INTERNAL for the whole
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
in fact, OCI_SetBindAllocation() only work for array interface because for
object like lobs, there is no way internally to find out the type of lob to
create (clob or lob)....
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am currently switching an application from using Pro*c to using OCILIB.
Everything works fine, except updating clobs.
When trying to update a clob, I always get an access violation in
oracommon9.dll trying to read address 0x45.
An example:
I am using OCILIB 3.9.2 on Oracle 9.2.0.8.
What am I doing wrong?
Regards,
Dries
Hi,
I searched the internet and found someone having a similar problem using plain
OCI: https://forums.oracle.com/forums/thread.jspa?threadID=194246 and I read
in the OCI documentation http://download.oracle.com/docs/cd/B13789_01/appdev.
101/b10779/oci05bnd.htm#432118.
So, after some debugging I changed:
into
This fixes the access violation and the data send to database looks ok.
Might this be a bug?
Regards,
Dries
Did you set OCI_bindArraySetSize() ??
No, I didn't.
If I do, it is working fine. But now another branch is executed in
OCI_BindAllocData and the code, that I changed before, is not executed.
are you binding an array of lob or just a single lob ?
If you're passing an array, you must use the array interface correctly and use
OCI_BindArraySetSize()
I am just binding a single lob.
I (mis)used OCI_BindArrayOfLobs as I could not get OCI_BindLob to do an
internal allocation.
When I do use OCI_BindLob with a given lob, does the statement clean up the
lob or should I call OCI_LobFree?
... // Initializing connection
string data;
int id;
... // Initializing DATA AND ID
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<char*>(data.c_str()), data.length()); </char*>
OCI_Execute(stmt);
The database layer am I migrating over from Pro*C is lot more dynamic than the
simple example I gave to demonstrate the problem. Adding the fact
OCI_BAM_INTERNAL and OCI_BindLob can not work together (gives an ORA-24813; it
looks like the OCILobLocator is never assigned to buf.data of the OCI_Bind), I
will use the array interface as you proposed.
Thanks for your help.
As I want use OCI_BAM_INTERNAL f
As I am using OCI_BAM_INTERNAL for the whole
OCI_BAM_INTERNAL and OCI_BindLob() should work together.
Do you still have an error if you replace, in the original code you've posted
the call to OCI_BindArrayOfLobs() by OCI_BindLob() ?
Replacing it by OCI_BindLob crashes because when called with data == NULL, the
type to use, expected in data->type, is not valid.
in fact, OCI_SetBindAllocation() only work for array interface because for
object like lobs, there is no way internally to find out the type of lob to
create (clob or lob)....