void Statement::collectParamResultsets() { Param::ParamType paramType; bool retrievedReturningIntoResultset = false; for(int i=0; i<params.size(); i++){ const Param *parameter=params.at(i); paramType=parameter->getParamType(); if(paramType==Param::Stmt){ Statement *childStmt=parameter->getStmtValue(); //OCI_SetFetchMode(childStmt->ociStatement(), OCI_SFM_SCROLLABLE); OCI_Resultset *ociResultSet=OCI_GetResultset(childStmt->ociStatement()); if(!ociResultSet){ DbUtil::checkForOciError(this); } this->resultsets.append(new Resultset(ociResultSet, this->connection, this)); }else if(paramType==Param::ReturningInto && !retrievedReturningIntoResultset){ OCI_Resultset *rs=OCI_GetResultset(ociStmt); if(rs!=0){ //will be 0 when affected record count is 0 this->resultsets.append(new Resultset(rs, this->connection, this)); retrievedReturningIntoResultset=true; } } } }
int main(void) { OCI_Connection *cn; OCI_Statement *st; OCI_Resultset *rs; char rowid[OCI_SIZE_ROWID + 1] = ""; if (!OCI_Initialize(err_handler, NULL, OCI_ENV_DEFAULT)) { return EXIT_FAILURE; } cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); st = OCI_StatementCreate(cn); OCI_Immediate(cn, "select rowid from products where code = 1", OCI_ARG_TEXT, rowid); OCI_Prepare(st, "select code, name, rowid from products where rowid = :id"); OCI_BindString(st, ":id", rowid, (unsigned int) strlen(rowid)); OCI_Execute(st); rs = OCI_GetResultset(st); OCI_FetchNext(rs); printf("code [%d], name [%s], rowid [%s]", OCI_GetInt(rs, 1), OCI_GetString(rs, 2), OCI_GetString(rs, 3)); OCI_StatementFree(st); OCI_ConnectionFree(cn); OCI_Cleanup(); return EXIT_SUCCESS; }
int main(void) { OCI_Connection *cn; OCI_Statement *st; OCI_Resultset *rs; if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); st = OCI_StatementCreate(cn); OCI_Prepare(st, "update products set code = code+10 returning code into :i"); OCI_RegisterInt(st, ":i"); OCI_Execute(st); rs = OCI_GetResultset(st); while (OCI_FetchNext(rs)) printf("%i\n", OCI_GetInt(rs, 1)); printf("count : %i\n", OCI_GetRowCount(rs)); OCI_Commit(cn); OCI_Cleanup(); return EXIT_SUCCESS; }
double get_estoque(requisicao_estoque *req) { double saldo; OCI_Statement *stmt = OCI_StatementCreate(oracledb); check_ociliberror(stmt); OCI_Prepare(stmt, "select sum(SALD_CTR) from table(saldo_inicial_tipoest(:emp, :est, :prod, :data, 'S', null, 0))"); OCI_BindShort(stmt, ":emp", &req->empresa); OCI_BindShort(stmt, ":est", &req->controle); OCI_BindString(stmt, ":prod", req->produto, 0); OCI_Date *d = OCI_DateCreate(NULL); OCI_DateSetDate(d, req->data_ano, req->data_mes, req->data_dia); OCI_BindDate(stmt, ":data", d); check_ociliberrorb(OCI_Execute(stmt)); OCI_Resultset *rs = OCI_GetResultset(stmt); check_ociliberror(rs); if (OCI_FetchNext(rs)) { saldo = OCI_GetDouble(rs, 1); } else { saldo = 0.0; } OCI_FreeStatement(stmt); return saldo; }
QueryResult Statement::doExecute() { Q_ASSERT(connection); if(connection->mutex.tryLock()){ print("Statement::doExecute called with unlocked mutex. This is a bug. The program will exit."); exit(1); } Q_ASSERT(prepared); Q_ASSERT(ociStmt); if(useScrollableResultsets){ OCI_SetFetchMode(ociStmt, OCI_SFM_SCROLLABLE); } int execResult=OCI_Execute(ociStmt); if(!execResult){ DbUtil::checkForOciError(this); } QueryResult queryResult; if(this->verb.isEmpty()){ this->verb=toQString(OCI_GetSQLVerb(ociStmt)); } if(this->statementType==OraExp::QueryTypeUnknown){ this->statementType=determineStatementType(); } if(statementType==OraExp::QueryTypeUpdate || statementType==OraExp::QueryTypeDelete || statementType==OraExp::QueryTypeInsert){ this->affectedRecordCount=OCI_GetAffectedRows(ociStmt); }//else if(statementType==OraExp::QueryTypeBegin || statementType==OraExp::QueryTypeDeclare){ collectParamResultsets(); //} DbUtil::checkForOciError(this); if(statementType==OraExp::QueryTypeSelect){ OCI_Resultset *ociResultSet=OCI_GetResultset(ociStmt); if(ociResultSet==NULL){ DbUtil::checkForOciError(this); } OCI_SetPrefetchSize(ociStmt, DB_PREFETCH_SIZE); OCI_SetFetchSize(ociStmt, DB_PREFETCH_SIZE); Q_ASSERT(this->resultsets.isEmpty()); this->resultsets.append(new Resultset(ociResultSet, connection, this)); } queryResult.statement=this; return queryResult; }
int ociw_query_result(db_wrap * self, char const * sql, size_t len, db_wrap_result ** tgt) { CONN_DECL(DB_WRAP_E_BAD_ARG); if (! sql || !*sql || !len || !tgt) return DB_WRAP_E_BAD_ARG; OCI_Statement * st = OCI_StatementCreate(ociconn); if (! st) { lerr("Creation of OCI_Statement failed.\n"); return DB_WRAP_E_CHECK_DB_ERROR; } db_wrap_result * wres = (db_wrap_result*)malloc(sizeof(db_wrap_result)); if (! wres) return DB_WRAP_E_ALLOC_ERROR; *wres = ociw_res_empty; ociw_result_impl * impl = (ociw_result_impl*)malloc(sizeof(ociw_result_impl)); if (! impl) { OCI_StatementFree(st); free(wres); return DB_WRAP_E_ALLOC_ERROR; } *impl = ociw_result_impl_empty; impl->st = st; wres->impl.data = impl; #if 1 if (! OCI_ExecuteStmt(st, sql)) { wres->api->finalize(wres); /* i don't quite know why, but fetching the OCI error state after this returns a 0 error code and empty error string. */ return DB_WRAP_E_CHECK_DB_ERROR; } #else if (! //OCI_ExecuteStmt(st, sql) OCI_Prepare(st, sql) ) { lerr("Preparation of OCI_Statement failed: [%s]\n",OCI_GetSql(st)); wres->api->finalize(wres); return DB_WRAP_E_CHECK_DB_ERROR; } if (! OCI_Execute(st)) { lerr("Execution of prepared OCI_Statement failed: [%s]\n",OCI_GetSql(st)); wres->api->finalize(wres); return DB_WRAP_E_CHECK_DB_ERROR; } #endif impl->result = OCI_GetResultset(st) /* MIGHT be null - the docs are not really clear here what happens on an empty result set. */ ; *tgt = wres; return 0; }
int main(void) { OCI_Connection *cn; OCI_Statement *st; OCI_Resultset *rs; product_t prd; product_ind_t ind; char buf[100]; int i = 0; if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); st = OCI_StatementCreate(cn); OCI_ExecuteStmt(st, "select * from products"); rs = OCI_GetResultset(st); OCI_SetStructNumericType(rs, 1, OCI_NUM_INT); OCI_SetStructNumericType(rs, 3, OCI_NUM_DOUBLE); while (OCI_FetchNext(rs)) { i++; OCI_GetStruct(rs, &prd, &ind); OCI_DateToText(prd.creation, "DD-MM-YYYY", 100, buf); printf("row #%d \n" "...prd.code : %d \n" "...prd.name : %s \n" "...prd.price : %g \n" "...prd.creation : %s \n" " \n", i, prd.code, prd.name, prd.price, buf ); } printf("\n\n%d row(s) fetched\n", OCI_GetRowCount(rs)); OCI_Cleanup(); return EXIT_SUCCESS; }
int main(void) { OCI_Connection *cn; OCI_Statement *st; OCI_Resultset *rs; OCI_Lob *lob1, *lob2; char temp[SIZE_BUF+1]; int code, n; if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); st = OCI_StatementCreate(cn); OCI_ExecuteStmt(st, "select code, content from test_lob for update"); rs = OCI_GetResultset(st); while (OCI_FetchNext(rs)) { code = OCI_GetInt(rs, 1); lob1 = OCI_GetLob(rs, 2); lob2 = OCI_LobCreate(cn, OCI_CLOB); n = OCI_LobWrite(lob1, "Today, ", 7); OCI_LobSeek(lob1, n, OCI_SEEK_SET); n = OCI_LobWrite(lob2, "I'm going to the cinema !", 25); OCI_LobAppendLob(lob1, lob2); OCI_LobSeek(lob1, 0, OCI_SEEK_SET); n = OCI_LobRead(lob1, temp, SIZE_BUF); temp[n] = 0; printf("code: %i, action : %s\n", code, temp); OCI_LobFree(lob2); } printf("\n%d row(s) fetched\n", OCI_GetRowCount(rs)); OCI_Cleanup(); return EXIT_SUCCESS; }
void long_oracle_call(void *data) { OCI_Statement *st = OCI_StatementCreate((OCI_Connection *) data); OCI_Resultset *rs; /* execute a query that takes a long time to process */ OCI_ExecuteStmt(st, "select code, content from huge_table"); rs = OCI_GetResultset(st); while (OCI_FetchNext(rs)) { printf("%i - %s", OCI_GetInt(rs, 1), OCI_GetString(rs, 2)); } SetEvent(evt); }
int main(void) { OCI_Connection *cn; OCI_Statement *st; OCI_Resultset *rs; int code = 1; char name[50]; if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); st = OCI_StatementCreate(cn); /* sql format with params ----------------------------------------------- */ OCI_ExecuteStmtFmt(st, "select article from test_fetch where code = %i", code); rs = OCI_GetResultset(st); while (OCI_FetchNext(rs)) printf("article : %s\n", OCI_GetString(rs, 1)); /* sql immediate (parse, exec, one fetch) ------------------------------- */ OCI_Immediate(cn, "select code, article from test_fetch where code = 1", OCI_ARG_INT, &code, OCI_ARG_TEXT, name); printf("article : %s - code %i\n", name, code); /* sql immediate (parse, exec, one fetch) with params ------------------- */ OCI_ImmediateFmt(cn, "select article from test_fetch where code = %i", code, OCI_ARG_TEXT, name); printf("article : %s\n", name); OCI_Cleanup(); return EXIT_SUCCESS; }
int main(void) { OCI_Connection *cn; OCI_Statement *st; OCI_Resultset *rs; OCI_Ref *ref; if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); st = OCI_StatementCreate(cn); OCI_ExecuteStmt(st, "select ref(e) from table_obj e"); rs = OCI_GetResultset(st); printf("\n\n=> fetch refs from object table\n\n"); while (OCI_FetchNext(rs)) { dump_ref(OCI_GetRef(rs, 1)); } printf("\n\n=> bind a local ref object to a PL/SQL statement\n\n"); ref = OCI_RefCreate(cn, OCI_TypeInfoGet(cn, "ARTICLE_T", OCI_TIF_TYPE)); OCI_Prepare(st, "begin " " select ref(e) into :r from table_obj e where e.id = 1; " "end; "); OCI_BindRef(st, ":r", ref); OCI_Execute(st); dump_ref(ref); OCI_RefFree(ref); OCI_Cleanup(); return EXIT_SUCCESS; }
int main(void) { OCI_Connection *cn; OCI_Statement *st; OCI_Resultset *rs; OCI_Coll *coll; OCI_Iter *iter; OCI_Elem *elem; OCI_TypeInfo *type; OCI_Object *obj; int i, n; if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); /* Varray binding -------------------------------------------------------- */ st = OCI_StatementCreate(cn); /* create the collection */ type = OCI_TypeInfoGet(cn, "Varray_type", OCI_TIF_TYPE); coll = OCI_CollCreate(type); /* bind the local collection to a PL/SQL procedure */ OCI_Prepare(st, "begin load_array(:array); end;"); OCI_BindColl(st, ":array", coll); OCI_Execute(st); /* the procedure has filled the collection and we can iterate it using an iterator */ iter = OCI_IterCreate(coll); elem = OCI_IterGetNext(iter); while (elem != NULL) { printf("value %s\n", OCI_ElemGetString(elem)); elem = OCI_IterGetNext(iter); } OCI_IterFree(iter); OCI_CollFree(coll); /* Varray SQL fetch ------------------------------------------------------- */ /* query on a table with varray column */ OCI_ExecuteStmt(st, "SELECT * from table_article"); rs = OCI_GetResultset(st); while (OCI_FetchNext(rs)) { /* iterate the collection using an iterator */ coll = OCI_GetColl(rs, 2); iter = OCI_IterCreate(coll); elem = OCI_IterGetNext(iter); printf("article #%d\n", OCI_GetInt(rs, 1)); while (elem != NULL) { obj = OCI_ElemGetObject(elem); printf(".... code %d, name%s \n", OCI_ObjectGetInt(obj, "ID"), OCI_ObjectGetString(obj, "NAME")); elem = OCI_IterGetNext(iter); } OCI_IterFree(iter); } /* Nested table fetch ------------------------------------------------------- */ /* query on a table with nested table column */ OCI_ExecuteStmt(st, "SELECT * from table_sales"); rs = OCI_GetResultset(st); while (OCI_FetchNext(rs)) { coll = OCI_GetColl(rs, 2); printf("Sale #%d\n", OCI_GetInt(rs, 1)); /* iterate the collection by accessing element by index */ n = OCI_CollGetSize(coll); for(i = 1; i <= n; i++) { elem = OCI_CollGetAt(coll, i); obj = OCI_ElemGetObject(elem); printf(".... employee %s, amount %s \n", OCI_ObjectGetString(obj, "EMP"), OCI_ObjectGetString(obj, "AMOUNT")); } } OCI_Cleanup(); return EXIT_SUCCESS; }
static HB_ERRCODE ocilibGoTo( SQLBASEAREAP pArea, HB_ULONG ulRecNo ) { OCI_Statement * st = ( ( SDDDATA * ) pArea->pSDDData )->pStmt; OCI_Resultset * rs = OCI_GetResultset( st ); while( ulRecNo > pArea->ulRecCount && ! pArea->fFetched ) { PHB_ITEM pArray; HB_USHORT ui; if( ! OCI_FetchNext( rs ) ) { pArea->fFetched = HB_TRUE; break; } pArray = hb_itemArrayNew( pArea->area.uiFieldCount ); for( ui = 1; ui <= pArea->area.uiFieldCount; ++ui ) { PHB_ITEM pItem = NULL; LPFIELD pField = pArea->area.lpFields + ui - 1; switch( pField->uiType ) { case HB_FT_STRING: if( OCI_IsNull( rs, ui ) ) { char * pStr = ( char * ) hb_xgrab( ( HB_SIZE ) pField->uiLen + 1 ); memset( pStr, ' ', pField->uiLen ); pStr[ pField->uiLen ] = '\0'; pItem = hb_itemPutCLPtr( NULL, pStr, pField->uiLen ); } else { const dtext * val; if( ( val = OCI_GetString( rs, ui ) ) != NULL ) pItem = D_HB_ITEMPUTSTRLEN( NULL, val, ( HB_SIZE ) dtslen( val ) ); /* TODO: Pad it to pField->uiLen size with spaces? */ } break; case HB_FT_LONG: case HB_FT_INTEGER: if( pField->uiDec == 0 ) #if HB_VMLONG_MAX == INT32_MAX || defined( HB_LONG_LONG_OFF ) pItem = hb_itemPutNIntLen( NULL, OCI_GetInt( rs, ui ), pField->uiLen ); #else pItem = hb_itemPutNIntLen( NULL, OCI_GetBigInt( rs, ui ), pField->uiLen ); #endif else pItem = hb_itemPutNDLen( NULL, OCI_GetDouble( rs, ui ), pField->uiLen, pField->uiDec ); break; case HB_FT_VARLENGTH: case HB_FT_MEMO: { OCI_Long * val = OCI_GetLong( rs, ui ); if( val ) { unsigned int uiSize = OCI_LongGetSize( val ); if( OCI_LongGetType( val ) == OCI_CLONG ) pItem = D_HB_ITEMPUTSTRLEN( NULL, ( D_HB_CHAR * ) OCI_LongGetBuffer( val ), uiSize ); else pItem = hb_itemPutCL( NULL, ( char * ) OCI_LongGetBuffer( val ), uiSize ); } break; } case HB_FT_IMAGE: case HB_FT_BLOB: case HB_FT_OLE: { OCI_Long * val = OCI_GetLong( rs, ui ); if( val ) pItem = hb_itemPutCL( NULL, ( char * ) OCI_LongGetBuffer( val ), OCI_LongGetSize( val ) ); break; } case HB_FT_CURRENCY: case HB_FT_CURDOUBLE: case HB_FT_FLOAT: case HB_FT_DOUBLE: pItem = hb_itemPutNDLen( NULL, OCI_GetDouble( rs, ui ), pField->uiLen, pField->uiDec ); break; case HB_FT_DATE: { OCI_Date * date = OCI_GetDate( rs, ui ); int iYear, iMonth, iDay; if( date && OCI_DateGetDate( date, &iYear, &iMonth, &iDay ) ) pItem = hb_itemPutD( NULL, iYear, iMonth, iDay ); break; } case HB_FT_TIME: { OCI_Date * date = OCI_GetDate( rs, ui ); int iYear, iMonth, iDay, iHour, iMin, iSec; if( date && OCI_DateGetDateTime( date, &iYear, &iMonth, &iDay, &iHour, &iMin, &iSec ) ) pItem = hb_itemPutTDT( NULL, hb_dateEncode( iYear, iMonth, iDay ), hb_timeEncode( iHour, iMin, iSec, 0 ) ); break; } case HB_FT_TIMESTAMP: { OCI_Timestamp * ts = OCI_GetTimestamp( rs, ui ); int iYear, iMonth, iDay, iHour, iMin, iSec, iFSec; if( ts && OCI_TimestampGetDateTime( ts, &iYear, &iMonth, &iDay, &iHour, &iMin, &iSec, &iFSec ) ) pItem = hb_itemPutTDT( NULL, hb_dateEncode( iYear, iMonth, iDay ), hb_timeEncode( iHour, iMin, iSec, iFSec / 1000000 ) ); break; } } if( pItem ) { hb_arraySetForward( pArray, ui, pItem ); hb_itemRelease( pItem ); } } if( pArea->ulRecCount + 1 <= pArea->ulRecMax ) { pArea->pRow = ( void ** ) hb_xrealloc( pArea->pRow, ( pArea->ulRecMax + SQLDD_ROWSET_RESIZE ) * sizeof( void * ) ); pArea->pRowFlags = ( HB_BYTE * ) hb_xrealloc( pArea->pRowFlags, ( pArea->ulRecMax + SQLDD_ROWSET_RESIZE ) * sizeof( HB_BYTE ) ); pArea->ulRecMax += SQLDD_ROWSET_RESIZE; } pArea->ulRecCount++; pArea->pRow[ pArea->ulRecCount ] = pArray; pArea->pRowFlags[ pArea->ulRecCount ] = SQLDD_FLAG_CACHED; }
static HB_ERRCODE ocilibOpen( SQLBASEAREAP pArea ) { OCI_Statement * st = OCI_StatementCreate( ( ( SDDCONN * ) pArea->pConnection->pSDDConn )->pConn ); OCI_Resultset * rs; SDDDATA * pSDDData; void * hQuery; HB_USHORT uiFields, uiIndex; PHB_ITEM pItemEof, pItem; HB_ERRCODE errCode; char * szError; HB_BOOL bError; pArea->pSDDData = memset( hb_xgrab( sizeof( SDDDATA ) ), 0, sizeof( SDDDATA ) ); pSDDData = ( SDDDATA * ) pArea->pSDDData; if( ! st ) { szError = ocilibGetError( &errCode ); hb_errRT_OCIDD( EG_OPEN, ESQLDD_STMTALLOC, szError, pArea->szQuery, errCode ); hb_xfree( szError ); return HB_FAILURE; } pItem = hb_itemPutC( NULL, pArea->szQuery ); if( ! OCI_ExecuteStmt( st, M_HB_ITEMGETSTR( pItem, &hQuery, NULL ) ) ) { hb_strfree( hQuery ); hb_itemRelease( pItem ); szError = ocilibGetError( &errCode ); OCI_StatementFree( st ); hb_errRT_OCIDD( EG_OPEN, ESQLDD_INVALIDQUERY, szError, pArea->szQuery, errCode ); hb_xfree( szError ); return HB_FAILURE; } else { hb_strfree( hQuery ); hb_itemRelease( pItem ); } rs = OCI_GetResultset( st ); uiFields = ( HB_USHORT ) OCI_GetColumnCount( rs ); SELF_SETFIELDEXTENT( ( AREAP ) pArea, uiFields ); pItemEof = hb_itemArrayNew( uiFields ); pItem = hb_itemNew( NULL ); #if 0 HB_TRACE( HB_TR_ALWAYS, ( "fieldcount=%d", iNameLen ) ); #endif errCode = 0; bError = HB_FALSE; for( uiIndex = 0; uiIndex < uiFields; ++uiIndex ) { DBFIELDINFO pFieldInfo; PHB_ITEM pName; OCI_Column * col = OCI_GetColumn( rs, uiIndex + 1 ); unsigned int uiDataType; unsigned int uiSize; int iDec; HB_BOOL bNullable; if( ! col ) { hb_itemRelease( pItemEof ); hb_itemRelease( pItem ); szError = ocilibGetError( NULL ); OCI_StatementFree( st ); hb_errRT_OCIDD( EG_OPEN, ESQLDD_STMTDESCR + 1001, szError, pArea->szQuery, 0 ); hb_xfree( szError ); return HB_FAILURE; } pName = D_HB_ITEMPUTSTR( NULL, OCI_ColumnGetName( col ) ); pFieldInfo.atomName = hb_itemGetCPtr( pName ); uiDataType = OCI_ColumnGetType( col ); uiSize = OCI_ColumnGetSize( col ); iDec = OCI_ColumnGetPrecision( col ); bNullable = ( HB_BOOL ) OCI_ColumnGetNullable( col ); if( bNullable ) pFieldInfo.uiFlags |= HB_FF_NULLABLE; pFieldInfo.uiLen = ( HB_USHORT ) uiSize; pFieldInfo.uiDec = ( HB_USHORT ) iDec; #if 0 HB_TRACE( HB_TR_ALWAYS, ( "field: name=%s type=%d len=%d dec=%d nullable=%d %d %d %d %d", pFieldInfo.atomName, uiDataType, uiSize, iDec, bNullable, OCI_ColumnGetScale( col ), OCI_ColumnGetPrecision( col ), OCI_ColumnGetFractionalPrecision( col ), OCI_ColumnGetLeadingPrecision( col ) ) ); #endif switch( uiDataType ) { case OCI_CDT_TEXT: pFieldInfo.uiType = HB_FT_STRING; break; case OCI_CDT_NUMERIC: pFieldInfo.uiType = HB_FT_LONG; /* For plain 'NUMERIC', precision is zero and scale is -127 */ if( OCI_ColumnGetPrecision( col ) > 0 ) pFieldInfo.uiLen = ( HB_USHORT ) OCI_ColumnGetPrecision( col ); if( OCI_ColumnGetScale( col ) >= 0 ) pFieldInfo.uiDec = ( HB_USHORT ) OCI_ColumnGetScale( col ); else pFieldInfo.uiDec = ( HB_USHORT ) hb_setGetDecimals(); break; case OCI_CDT_LONG: pFieldInfo.uiType = HB_FT_VARLENGTH; break; case OCI_CDT_RAW: pFieldInfo.uiType = HB_FT_BLOB; break; case OCI_CDT_DATETIME: case OCI_CDT_TIMESTAMP: case OCI_CDT_INTERVAL: pFieldInfo.uiType = HB_FT_TIME; break; default: #if 0 HB_TRACE( HB_TR_ALWAYS, ( "new sql type=%d", uiDataType ) ); #endif bError = HB_TRUE; errCode = ( HB_ERRCODE ) uiDataType; pFieldInfo.uiType = 0; pFieldInfo.uiType = HB_FT_STRING; break; } if( ! bError ) { switch( pFieldInfo.uiType ) { case HB_FT_STRING: { char * pStr = ( char * ) hb_xgrab( ( HB_SIZE ) pFieldInfo.uiLen + 1 ); memset( pStr, ' ', pFieldInfo.uiLen ); pStr[ pFieldInfo.uiLen ] = '\0'; hb_itemPutCLPtr( pItem, pStr, pFieldInfo.uiLen ); break; } case HB_FT_MEMO: case HB_FT_VARLENGTH: case HB_FT_BLOB: hb_itemPutC( pItem, NULL ); break; case HB_FT_INTEGER: hb_itemPutNI( pItem, 0 ); break; case HB_FT_LONG: if( pFieldInfo.uiDec == 0 ) hb_itemPutNLLen( pItem, 0, pFieldInfo.uiLen ); else hb_itemPutNDLen( pItem, 0.0, pFieldInfo.uiLen, pFieldInfo.uiDec ); break; case HB_FT_DOUBLE: hb_itemPutNDLen( pItem, 0.0, pFieldInfo.uiLen, pFieldInfo.uiDec ); break; case HB_FT_LOGICAL: hb_itemPutL( pItem, HB_FALSE ); break; case HB_FT_DATE: hb_itemPutDL( pItem, 0 ); break; case HB_FT_TIME: case HB_FT_TIMESTAMP: hb_itemPutTDT( pItem, 0, 0 ); break; default: hb_itemClear( pItem ); bError = HB_TRUE; } hb_arraySetForward( pItemEof, uiIndex + 1, pItem ); if( ! bError ) bError = ( SELF_ADDFIELD( ( AREAP ) pArea, &pFieldInfo ) == HB_FAILURE ); } hb_itemRelease( pName ); if( bError ) break; } hb_itemRelease( pItem ); if( bError ) { hb_itemRelease( pItemEof ); OCI_StatementFree( st ); hb_errRT_OCIDD( EG_CORRUPTION, ESQLDD_INVALIDFIELD, "Invalid field type", pArea->szQuery, errCode ); return HB_FAILURE; } pArea->ulRecCount = 0; pArea->ulRecMax = SQLDD_ROWSET_INIT; pArea->pRow = ( void ** ) hb_xgrab( SQLDD_ROWSET_INIT * sizeof( void * ) ); memset( pArea->pRow, 0, SQLDD_ROWSET_INIT * sizeof( void * ) ); pArea->pRowFlags = ( HB_BYTE * ) hb_xgrab( SQLDD_ROWSET_INIT * sizeof( HB_BYTE ) ); memset( pArea->pRowFlags, 0, SQLDD_ROWSET_INIT * sizeof( HB_BYTE ) ); pArea->pRow[ 0 ] = pItemEof; pArea->pRowFlags[ 0 ] = SQLDD_FLAG_CACHED; pSDDData->pStmt = st; return HB_SUCCESS; }