/* This function takes a valid LOB locator and prints the character set form of the LOB. */ void getCsformLOB_proc(OCILobLocator *Lob_loc, OCIEnv *envhp, OCIError *errhp, OCISvcCtx *svchp, OCIStmt *stmthp) { ub1 charset_form = 0 ; printf ("----------- OCILobCharSetForm Demo --------------\n"); printf (" get the character set form of ad_fltextn\n"); /* Get the charactersid form of the LOB*/ checkerr (errhp, OCILobCharSetForm(envhp, errhp, Lob_loc, &charset_form)); printf(" character Set Form of ad_fltextn is : %d\n", charset_form); return; }
DB_ROW zbx_db_fetch(DB_RESULT result) { #if defined(HAVE_IBM_DB2) int i; #elif defined(HAVE_ORACLE) int i; sword rc; static char errbuf[512]; sb4 errcode; #endif if (NULL == result) return NULL; #if defined(HAVE_IBM_DB2) if (SUCCEED != zbx_ibm_db2_success(SQLFetch(result->hstmt))) /* e.g., SQL_NO_DATA_FOUND */ return NULL; for (i = 0; i < result->ncolumn; i++) { result->values[i] = (SQL_NULL_DATA == result->values_len[i] ? NULL : result->values_cli[i]); } return result->values; #elif defined(HAVE_MYSQL) return mysql_fetch_row(result); #elif defined(HAVE_ORACLE) if (OCI_NO_DATA == (rc = OCIStmtFetch2(result->stmthp, oracle.errhp, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT))) return NULL; for (i = 0; i < result->ncolumn; i++) { if (NULL != result->clobs[i]) { ub4 alloc, amount, amt = 0; ub1 csfrm; rc = OCILobGetLength(oracle.svchp, oracle.errhp, result->clobs[i], &amount); if (OCI_SUCCESS != rc) break; rc = OCILobCharSetForm(oracle.envhp, oracle.errhp, result->clobs[i], &csfrm); if (OCI_SUCCESS != rc) break; if (result->values_alloc[i] < (alloc = amount * 4 + 1)) { result->values_alloc[i] = alloc; result->values[i] = zbx_realloc(result->values[i], result->values_alloc[i]); } amt = amount; rc = OCILobRead(oracle.svchp, oracle.errhp, result->clobs[i], &amt, (ub4)1, (dvoid *)result->values[i], (ub4)(result->values_alloc[i] - 1), (dvoid *)NULL, (OCICallbackLobRead)NULL, (ub2)0, csfrm); if (OCI_SUCCESS != rc) zabbix_errlog(ERR_Z3006, rc, zbx_oci_error(rc)); result->values[i][amt] = '\0'; } } if (OCI_SUCCESS == rc) return result->values; if (OCI_SUCCESS != (rc = OCIErrorGet((dvoid *)oracle.errhp, (ub4)1, (text *)NULL, &errcode, (text *)errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR))) { zabbix_errlog(ERR_Z3006, rc, zbx_oci_error(rc)); return NULL; } switch (errcode) { case 3113: /* ORA-03113: end-of-file on communication channel */ case 3114: /* ORA-03114: not connected to ORACLE */ zabbix_errlog(ERR_Z3006, errcode, errbuf); return NULL; } return result->values; #elif defined(HAVE_POSTGRESQL) /* free old data */ if (NULL != result->values) zbx_free(result->values); /* EOF */ if (result->cursor == result->row_num) return NULL; /* init result */ result->fld_num = PQnfields(result->pg_result); if (result->fld_num > 0) { int i; result->values = zbx_malloc(result->values, sizeof(char *) * result->fld_num); for (i = 0; i < result->fld_num; i++) { if (PQgetisnull(result->pg_result, result->cursor, i)) { result->values[i] = NULL; } else { result->values[i] = PQgetvalue(result->pg_result, result->cursor, i); if (PQftype(result->pg_result, i) == ZBX_PG_BYTEAOID) /* binary data type BYTEAOID */ zbx_pg_unescape_bytea((u_char *)result->values[i]); } } } result->cursor++; return result->values; #elif defined(HAVE_SQLITE3) /* EOF */ if (result->curow >= result->nrow) return NULL; if (NULL == result->data) return NULL; result->curow++; /* NOTE: first row == header row */ return &(result->data[result->curow * result->ncolumn]); #endif }