Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Calling OCILobWrite in Pro-C fails - any idea?
I'm using VC++ with Oracle NT 8.0.5 proc and I'm trying to write some
data into a BLOB using the OCILobWrite call. Unfortunatly, OCILobWrite
always returns -2 (OCI_INVALID_HANDLE). The code looks ok for me - any
idea?
Here's the code excluding error handling:
void write_blob(char *bytes,int bytes_length)
{
OCIEnv *envhp;
OCISvcCtx *oschp;
OCIError *errhp;
EXEC SQL BEGIN DECLARE SECTION;
char *uid = "USER/PASS";
OCIBlobLocator *blob;
EXEC SQL END DECLARE SECTION;
ub4 amt = bytes_length;
EXEC SQL CONNECT :uid;
// allocate an oci env handle
status= SQLEnvGet(SQL_SINGLE_RCTX, &envhp);
// allocate an error handle
status = OCIHandleAlloc((dvoid *)envhp, (dvoid **)&errhp,
(ub4) OCI_HTYPE_ERROR, (ub4 )0, (dvoid **) 0);
// allocate an oci service context
status = SQLSvcCtxGet(SQL_SINGLE_RCTX, "", 0, &oschp);
EXEC SQL ALLOCATE :blob;
result = OCILobWrite(oschp, errhp, blob, &amt, 1, (dvoid *) bytes,
(ub4) amt, OCI_ONE_PIECE, (dvoid *)0, (sb4 (*)(dvoid *, dvoid *, ub4 *, ub1 *)) 0, (ub2) 0, (ub1) SQLCS_IMPLICIT);
// result == -2
Thanx for any replies!
Greeings
Constantin Szallies
Received on Thu Apr 22 1999 - 03:51:03 CDT