| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> OCI: Write BLOB's
Hallo,
I wrote a class to encapsulate Insert statements and now I want to insert
blob's.
The statement looks like:
insert into foo (b,c) values (:0, :1)
where b is a blob column.
I have found that if I write the statement like above I have to initialize
the lob locator
before I bind it. So I do the following (buffered statement):
... // init the blob column
ub4 loc_empty = 0;
for (c=0;c < row_size;c++)
{ ....
// bei c == 0 -->
// set all loc empty
for (r=0;r < nrows;r++)
{ OCIDescriptorAlloc(env, &row[c].blob[r], (ub4)OCI_DTYPE_LOB, 0,
NULL);
OCIAttrSet(row[c].blob[r], OCI_DTYPE_LOB, &loc_empty,
sizeof(loc_empty),
OCI_ATTR_LOBEMPTY, error);
}
OCIBindByPos(hstmt, &row[c].hbnd, error, c+1,
&row[c].blob[0], sizeof(void*), row[c].dty,
&row[c].nidx[0], NULL, NULL, 0, NULL, OCI_DEFAULT);
OCIBindArrayOfStruct(row[c].hbnd, error,(sb4)row[c].size, 0,0,0);
}
const char* buff = "test test test test test test test test";
ub4 amtp;
dword bsz, off=1;
bsz = amtp = strlen(buff);
OCILobWrite(ctx, error, row[c].blob[0], &amtp, off, // I
really want to write at blob 0
buff, bsz, OCI_ONE_PIECE, NULL, NULL, 0,
(ub1)SQLCS_IMPLICIT);
But this call return -2 (OCI_INVALID_HANDLE). Where is the problem? I hope somebody can help me.
Thanks in advance,
Axel
Received on Tue Dec 11 2001 - 03:36:30 CST
![]() |
![]() |