Home » Developer & Programmer » Precompilers, OCI & OCCI » ORA-1405
ORA-1405 [message #93969] Wed, 11 June 2003 02:50
petra
Messages: 5
Registered: April 2002
Junior Member
Hello,
I have a crazy problem. When I execute a Statement like
"select e.extract('XPathExpression').getClobVal() from table e" on the sqlplus command line, I get results.
When I execute the same Statement in an oci-Programm, I
get an ORA-01405 error message, although I know that the statement is correct and I receive results on sqlplus.
With other Statements I have no problems in my oci-Programm.

Here is the code:
ub4 amtp, nbytes;
ub1 bufp[[MAXBUFLEN]];
ub4 colc = 0;
sword stat=OCI_NO_DATA;
string result;
OCILobLocator *clob;
OCIStmt *stmthp = (OCIStmt *)0;
OCIDefine *defnp = (OCIDefine *)0;
OCIBind *bndhp1 = (OCIBind *) 0;

cout<<(char *) request<<endl;
checkerr(errhp, OCIHandleAlloc(envhp, (dvoid **)&stmthp, OCI_HTYPE_STMT, (size_t)0,
(dvoid **)0));

/* Allocate the lob descriptor */
if (OCIDescriptorAlloc((dvoid *) envhp, (dvoid **) &clob,
(ub4)OCI_DTYPE_LOB, (size_t) 0, (dvoid **) 0))
{
printf("FAILED: OCIDescriptorAlloc()n");
checkerr(errhp, stat);

}

/* prepare select statement */
if (stat = OCIStmtPrepare(stmthp, errhp, (text *)request,
(ub4) strlen((char *)request),
(ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT))
{
printf("FAILED: OCIStmtPrepare() selstmtn");
checkerr(errhp, stat);

}

/* associate variable colc with bind placeholder #1 in the SQL statement */
/* if (stat = OCIBindByPos(stmthp, &bndhp1, errhp, (ub4) 1,
(dvoid *) &colc, (sb4) sizeof(colc), SQLT_INT,
(dvoid *) 0, (ub2 *)0, (ub2 *)0,
(ub4) 0, (ub4 *) 0, (ub4) OCI_DEFAULT))
{
printf("FAILED: OCIBindByPos()n");
checkerr(errhp, stat);

}*/

/* associate lob var with its define handle */
if (stat = OCIDefineByPos(stmthp, &defnp, errhp, (ub4) 1,
(dvoid *) &clob, (sb4) -1, (ub2) SQLT_CLOB,
(dvoid *) 0, (ub2 *) 0, (ub2 *) 0, (ub4) OCI_DEFAULT))
{
printf("FAILED: OCIDefineByPos() CLOBn");
checkerr(errhp, stat);

}

/* execute the select statement */
if (stat = OCIStmtExecute(svchp, stmthp, errhp, (ub4) 1, (ub4) 0,
(CONST OCISnapshot*) 0, (OCISnapshot*) 0,
(ub4) OCI_DEFAULT))
{
printf("FAILED: OCIStmtExecute() selstmtn");
checkerr(errhp, stat);

}

/* read the fetched value into a buffer */
amtp = nbytes = MAXBUFLEN-1;
if (stat = OCILobRead(svchp, errhp, clob, &amtp,
(ub4) 1, (dvoid *) bufp, (ub4) nbytes, (dvoid *)0,
(sb4 (*)(dvoid *, CONST dvoid *, ub4, ub1)) 0,
(ub2) 0, (ub1) SQLCS_IMPLICIT))
{
printf("FAILED: OCILobRead() n");
checkerr(errhp, stat);

}
bufp[[amtp]] = '';

/* Print out the buffer */
if (amtp > 0) {
printf("n=> Query result of %s on row %d: n%sn", request,1, bufp);
char *x=(char*)bufp;
result=string(x);
}

else {
printf("nEmpty valuen");
}

/* Free the lob locator */
if (clob) {
OCIDescriptorFree((dvoid *) clob, (ub4) OCI_DTYPE_LOB);
}

return result;
Previous Topic: How to keep all date info when using sqlda
Next Topic: why does default makefile trying to remove libclntsh.sl.9.0? Is it ok, if I set permission to remove
Goto Forum:
  


Current Time: Sun Nov 24 14:58:12 CST 2024