Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> What's wrong ? OCI-8 programming

What's wrong ? OCI-8 programming

From: Eric DANTIE <edantie_at_rcanaria.es>
Date: Tue, 22 Dec 1998 14:35:45 +0000
Message-ID: <367FAE41.44810333@rcanaria.es>


When I try to get execute this function, I've got a ORA-01405: fetched column value is NULL

And that's true: I have some null datas in the table.

I just want to print "NULL" when its NULL and continue, with the others fields.

Thanks in advance.

Eric

void PrintSELECT(char *sql) {

	sword status;
	int i;
	ub4 nbcol;
	OCIParam *colhd;
	char col[256];
	ub2 type[255];
	char binds[256][256];
	text name[256];
	ub4 len;
	
	checkerr(errhp, OCIHandleAlloc( (dvoid *) envhp, (dvoid **) &stmthp,
		OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0));

	checkerr(errhp, OCIStmtPrepare(stmthp, errhp, sql, 

(ub4) strlen((char *) sql),
(ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT));
checkerr(errhp,OCIStmtExecute(svchp, stmthp, errhp, (ub4) 1, (ub4) 0,
(CONST OCISnapshot *) NULL, (OCISnapshot *) NULL, OCI_DESCRIBE_ONLY));
checkerr(errhp,OCIAttrGet(stmthp, OCI_HTYPE_STMT, &nbcol, 0,
OCI_ATTR_PARAM_COUNT, errhp));
	for (i=1;i<=nbcol;i++) {
		checkerr(errhp, OCIDefineByPos(stmthp, &defnp, errhp, i, (dvoid *)
&binds[i],
			255, SQLT_STR, (dvoid *) 0, (ub2 *)0,
			(ub2 *)0, OCI_DEFAULT));

	}

	status = OCIStmtExecute(svchp, stmthp, errhp, (ub4) 1, (ub4) 0, 

(CONST OCISnapshot *) NULL, (OCISnapshot *) NULL, OCI_DEFAULT);
while (status != OCI_NO_DATA) { checkerr(errhp,status); for (i=1;i<nbcol;i++) { printf("%s ",binds[i]); } printf("\n"); status = OCIStmtFetch(stmthp, errhp, 1, OCI_FETCH_NEXT, OCI_DEFAULT); } checkerr(errhp, OCIHandleFree((dvoid *) stmthp, OCI_HTYPE_STMT));

} Received on Tue Dec 22 1998 - 08:35:45 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US