// ----------------------------------------------------------------------------- // PosLmIconHandler::GetIconPathL // // (other items were commented in a header). // ----------------------------------------------------------------------------- // TInt PosLmIconHandler::GetIconPathL( CPosLmLocalDbAccess& aDbAccess, TUint32 aIconPathId, TDes& aIconPath) { HBufC* sql = HBufC::NewLC(KPosLmSqlStatementMaxLen); sql->Des().Format(KPosLmSqlFindUint, &KPosLmIconPathCol, &KPosLmIconTable, &KPosLmIconIdCol, aIconPathId); RDbView view; aDbAccess.PrepareViewLC(CPosLmLocalDbAccess::EUpdatablePreparation, view, *sql); TInt iconPathFound = KErrNotFound; if (view.FirstL()) { view.GetL(); PosLmLongTextColHandler::ReadFromLongTextColumnL(aIconPath, view, 1); iconPathFound = KErrNone; } CleanupStack::PopAndDestroy(2, sql); //&view return iconPathFound; }
// ----------------------------------------------------------------------------- // PosLmIconHandler::GetIconPathIdL // // (other items were commented in a header). // ----------------------------------------------------------------------------- // void PosLmIconHandler::GetIconPathIdL( CPosLmLocalDbAccess& aDbAccess, const TDesC& aIconPath, TUint32& aIconPathId) { // First search icon table for icon path HBufC* sql = HBufC::NewLC(KPosLmSqlStatementMaxLen+KMaxFileName); sql->Des().Format(KPosLmSqlFindString, &KPosLmIconIdCol, &KPosLmIconTable, &KPosLmIconPathCol, &aIconPath); RDbView view; aDbAccess.PrepareViewLC( CPosLmLocalDbAccess::EUpdatablePreparation, view, *sql); if (!view.NextL()) { // Icon path not found. Add icon path to database. AddIconPathL(aDbAccess, aIconPath, aIconPathId); } else { // Icon path found. Fetch number. view.GetL(); aIconPathId = view.ColUint32(1); } CleanupStack::PopAndDestroy(2, sql); //&view }
TInt CSCPParamDB :: GetValueForParameterL(TInt aParamID, TInt32& aValue, TInt32& aApp) { _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL >>>")); RDbView lDBView; CleanupClosePushL(lDBView); HBufC* lSelectQry = HBufC :: NewLC(KSelectWhereParamId().Length() + 15); lSelectQry->Des().Format(KSelectWhereParamId, aParamID); __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry))); __LEAVE_IF_ERROR(lDBView.EvaluateAll()); if( lDBView.FirstL()) { TInt lRowCount = lDBView.CountL(); if(lRowCount == 0) { _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter")); CleanupStack :: PopAndDestroy(2); return KErrNotFound; } else if(lRowCount > 1) { _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: More than one record matches the criterion. Db is corrupt! Leaving...")); User :: Leave(KErrCorrupt); } lDBView.GetL(); aApp = lDBView.ColInt(iColSet->ColNo(KColAppId)); aValue = lDBView.ColInt(iColSet->ColNo(KColValueInt)); } CleanupStack :: PopAndDestroy(2); _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL <<<")); return KErrNone; }
// --------------------------------------------------------------------------- // CFotaDB::GetStateL // Gets pkg state from db // --------------------------------------------------------------------------- TPackageState CFotaDB::GetStateL(const TInt aPkgId, TDes8& aPkgURL) { RDbView view; TPackageState s; CleanupClosePushL(view); s.iState = RFotaEngineSession::EIdle; // default state is idle HBufC* select = HBufC::NewLC(KSelect_where_packageid().Length() + 10); select->Des().Format(KSelect_where_packageid, aPkgId); TInt err = view.Prepare(iStateDB, TDbQuery(*select)); __LEAVE_IF_ERROR(err); view.EvaluateAll(); view.FirstL(); while (view.AtRow()) { view.GetL(); HBufC8* url; s = RowToStateL(url, view); CleanupStack::PushL(url); aPkgURL.Copy(url->Des()); CleanupStack::PopAndDestroy(); // url view.NextL(); } CleanupStack::PopAndDestroy(); //select CleanupStack::PopAndDestroy(); //view return s; }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CScheduleDB::ReadDbItemsL(RPointerArray<CMsgStored>& aItemArray) { aItemArray.ResetAndDestroy();// first reset the array TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM "));// just get all columns & rows QueryBuffer.Append(KtxtItemlist2); RDbView Myview; Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.EvaluateAll(); Myview.FirstL(); while(Myview.AtRow()) // Just delete one instance of the message { Myview.GetL(); CMsgStored* NewItem = new(ELeave)CMsgStored(); aItemArray.Append(NewItem); NewItem->iIndex = Myview.ColInt32(1); NewItem->iMessage = Myview.ColDes(2).AllocL(); Myview.NextL(); } CleanupStack::PopAndDestroy(1); // Myview }
// -------------------------------- // CNSmlRoamTable::GetItemIAPL( TInt aProfileId, TInt aPriority ) // Return IAP for profile id and priority // -------------------------------- // EXPORT_C TUint32 CNSmlRoamTable::GetItemIAPL( TInt aProfileId, TInt aPriority ) { RDbView view; CleanupClosePushL(view); TUint32 uint(0); TBuf<KNSmlMaxSQLLength> sqlBuf; sqlBuf.Format( KSQLSelectUint, aProfileId, aPriority ); view.Prepare(iDatabase, TDbQuery( sqlBuf )); view.EvaluateAll(); if ( view.IsEmptyL() ) { User::Leave( KErrNotFound ); } view.FirstL(); view.GetL(); uint = view.ColUint( iColSet->ColNo( KColIapId )); CleanupStack::PopAndDestroy(); //view return uint; }
// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // TBool PosLmLandmarkHandler::ReadIconPathIdL( CPosLmLocalDbAccess& aDbAccess, const TPosLmItemId& aLandmarkId, TUint32& aIconPathId) { HBufC* sql = HBufC::NewLC(KPosLmSqlStatementMaxLen); sql->Des().Format(KPosLmSqlFindUint, &KPosLmIconIdCol, &KPosLmLandmarkTable, &KPosLmLandmarkIdCol, aLandmarkId); RDbView view; aDbAccess.PrepareViewLC(CPosLmLocalDbAccess::EUpdatablePreparation, view, *sql); TBool iconIsSet = EFalse; if (view.NextL()) { view.GetL(); if (!view.IsColNull(1)) { aIconPathId = view.ColUint32(1); iconIsSet = ETrue; } } CleanupStack::PopAndDestroy(2, sql); //&view return iconIsSet; }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CScheduleDB::DeleteFromDatabaseL(TInt& aIndex) { TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM ")); QueryBuffer.Append(KtxtItemlist); QueryBuffer.Append(_L(" WHERE ")); QueryBuffer.Append(NCol0); QueryBuffer.Append(_L(" = ")); QueryBuffer.AppendNum(aIndex); iItemsDatabase.Begin(); RDbView Myview; // query buffr with index finds only the selected item row. Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.EvaluateAll(); Myview.FirstL(); // we have autoincrement in index so it should be unique // but just to make sure, we use 'while', instead of 'if' while(Myview.AtRow()) { Myview.GetL(); Myview.DeleteL(); Myview.NextL(); } CleanupStack::PopAndDestroy(1); // Myview iItemsDatabase.Commit(); // compacts the databse, by physicaly removig deleted data. iItemsDatabase.Compact(); }
TInt CSCPParamDB :: GetApplicationIDListL(RArray <TUid>& aIDArray) { _SCPDB_LOG(_L("[CSCPParamDB]-> GetApplicationIDList() >>>")); RDbView lDBView; CleanupClosePushL(lDBView); HBufC* lSelectQry = HBufC :: NewLC(KSelectAll().Length()); lSelectQry->Des().Append(KSelectAll); __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry))); __LEAVE_IF_ERROR(lDBView.EvaluateAll()); TBool lStatus(EFalse); TInt lRet(KErrNone); TRAP(lRet, lStatus = lDBView.FirstL()); if(lRet == KErrNone && lStatus) { do { lDBView.GetL(); TUid lAppUID = TUid :: Uid(lDBView.ColInt(iColSet->ColNo(KColAppId))); if(aIDArray.Find(lAppUID) == KErrNotFound) { aIDArray.AppendL(lAppUID); } } while(lDBView.NextL()); } _SCPDB_LOG(_L("[CSCPParamDB]-> GetApplicationIDList() >>>")); CleanupStack :: PopAndDestroy(2); return KErrNone; }
// --------------------------------------------------------------------------- // CFotaDB::GetAllL // Get all states // --------------------------------------------------------------------------- void CFotaDB::GetAllL(RArray<TInt>& aStates) { RDbView view; CleanupClosePushL(view); TInt err = view.Prepare(iStateDB, TDbQuery(KSelectAll)); __LEAVE_IF_ERROR(err); view.EvaluateAll(); view.FirstL(); FLOG(_L("[fota DB] --- rows ------------------------------------------------------------------- v")); while (view.AtRow()) { view.GetL(); HBufC8* url; TPackageState s = RowToStateL(url, view); aStates.Append(s.iPkgId); CleanupStack::PushL(url); FLOG(_L("[fotaDB] pkgid: %d profid:%d state:%d result:%d \ url: %d chars sessiontype:%d IapId:%d Pkgsize:%d UpdateLtr:%d"), s.iPkgId, s.iProfileId, s.iState, s.iResult, url->Des().Length(), s.iSessionType, s.iIapId, s.iPkgSize, s.iUpdateLtr); CleanupStack::PopAndDestroy(); // url view.NextL(); } FLOG(_L("[fota DB] --- rows ------------------------------------------------------------------- ^")); view.Close(); CleanupStack::PopAndDestroy(); //view }
void CExPolicy_Server::ReadDbItemsL(TBool aImsi) { TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM "));// just get all columns & rows if(aImsi) QueryBuffer.Append(KtxtImsilist); else QueryBuffer.Append(KtxtNumberlist); RDbView Myview; Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.EvaluateAll(); Myview.FirstL(); while(Myview.AtRow()) // Just delete one instance of the message { Myview.GetL(); TExampleItem NewItem; NewItem.iIndex = Myview.ColInt(1); NewItem.iName.Copy(Myview.ColDes(2)); NewItem.iValue.Copy(Myview.ColDes(3)); if(aImsi) iImsiArray.Append(NewItem); else iNumberArray.Append(NewItem); Myview.NextL(); } CleanupStack::PopAndDestroy(1); // Myview }
// ----------------------------------------------------------------------------- // CWPInternetAPDB::ReadItemsL // ----------------------------------------------------------------------------- // void CSCOMOAdapterDb::ReadItemsL(RPointerArray<CAMDbItem>& aItemArray, TDesC& aSqlQuery) { RDbView view; view.Prepare(iDatabase, TDbQuery(aSqlQuery)); CleanupClosePushL(view); view.EvaluateAll(); view.FirstL(); while (view.AtRow()) { view.GetL(); CAMDbItem *dbitem = new(ELeave) CAMDbItem; dbitem->id = view.ColInt(1); dbitem->iLUID = view.ColInt(2); dbitem->iProfileId = view.ColInt(3); dbitem->iServerID = (view.ColDes8(4)).AllocL(); dbitem->iCorrelator = (view.ColDes8(5)).AllocL(); dbitem->iSourceURI = (view.ColDes8(6)).AllocL(); dbitem->iRetryCount = view.ColInt(7); aItemArray.AppendL(dbitem); view.NextL(); } CleanupStack::PopAndDestroy(); // view }
void CDscDatabase::GetDscDescriptionL(const TUid &aDscId, TDes& aDescription) const { RDbView view; CleanupClosePushL(view); RBuf sqlCmd; CleanupClosePushL(sqlCmd); sqlCmd.CreateL(KSqlSelectDscDescriptionLength); sqlCmd.Format(KSqlSelectDscDescription, &KDescriptionCol, &KDscTable, &KDscIdCol, aDscId); DebugPrint(sqlCmd); User::LeaveIfError(view.Prepare(iDatabase, sqlCmd)); User::LeaveIfError(view.EvaluateAll()); CleanupStack::PopAndDestroy(&sqlCmd); if(view.IsEmptyL()) { User::Leave(KErrNotFound); } view.FirstL(); view.GetL(); //Check the length of aDescription TPtrC description(view.ColDes(1)); if (description.Length() > aDescription.MaxLength()) { User::Leave(KErrOverflow); } aDescription.Zero(); aDescription=description; CleanupStack::PopAndDestroy(&view); }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ TBool CExPolicy_Server::OkToAddToValDb(RDbDatabase& aDatabase,const TDesC& aCode,const TDesC8& aString) { TBool Ret(ETrue); TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM ")); QueryBuffer.Append(KtxtVallist); RDbView Myview; Myview.Prepare(aDatabase,TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.EvaluateAll(); Myview.FirstL(); QueryBuffer.Copy(aString); while(Myview.AtRow()) // Just delete one instance of the message { Myview.GetL(); if(QueryBuffer == Myview.ColDes(3) && aCode == Myview.ColDes(2)) { Ret = EFalse; break; } Myview.NextL(); } CleanupStack::PopAndDestroy(1); // Myview return Ret; }
TInt CSCOMOAdapterDb::GetRetryCountForLuidL(TInt aLuid) { TInt retrycount = KErrNone; TFileName sqlQuery; PrepareLuidQuery(aLuid, sqlQuery); BeginDatabaseTransaction(); RDbView view; view.Prepare(iDatabase, TDbQuery(sqlQuery)); CleanupClosePushL(view); view.EvaluateAll(); view.FirstL(); if (!view.IsEmptyL()) { if(view.AtRow()) { view.GetL(); } retrycount = view.ColInt(7); } CleanupStack::PopAndDestroy(1); // view CommitDatabaseTransaction(); return retrycount; }
// ----------------------------------------------------------------------------- // CWPInternetAPDB::ReadItemsL // ----------------------------------------------------------------------------- // void CWPInternetAPDB::ReadItemsL(RArray<TAccessPointItem>& aItemArray, TFileName QueryBuffer) { FLOG( _L( "[Provisioning] CWPInternetAPDB::ReadItemsL" ) ); RDbView Myview; Myview.Prepare(iItemsDatabase, TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.EvaluateAll(); if ( Myview.FirstL()) { while (Myview.AtRow()) { Myview.GetL(); TAccessPointItem AccessPointItem; AccessPointItem.iIndex = Myview.ColInt(1); AccessPointItem.iAPID = Myview.ColInt(2); AccessPointItem.iBearerType = Myview.ColInt(3); AccessPointItem.iOriginator.Copy(Myview.ColDes(4)); aItemArray.Append(AccessPointItem); Myview.NextL(); } } CleanupStack::PopAndDestroy(); // Myview FLOG( _L( "[Provisioning] CWPInternetAPDB::ReadItemsL: done" ) ); }
static void ViewTestL() { RDbView view; CleanupClosePushL(view); TheTest.Next(_L("Prepare()")); TInt err = view.Prepare(TheDb1, TDbQuery(_L("SELECT * FROM ATbl"))); TEST2(err, KErrNone); TheTest.Next(_L("Update()")); TBool res = view.FirstL(); TEST(res); view.GetL(); view.UpdateL(); view.SetColL(2, 100); view.SetColL(3, 200); view.PutL(); CleanupStack::PopAndDestroy(&view); TheTest.Next(_L("Prepare() with an update sql")); CleanupClosePushL(view); err = view.Prepare(TheDb1, TDbQuery(_L("UPDATE ATbl SET DATA1 = 400 WHERE ID = 0"))); TEST2(err, KErrArgument); CleanupStack::PopAndDestroy(&view); }
/** Helper function. Get the next available itemId for the item. Reads all existing ItemIds for the specified DscId, then calculates last+1 or first-1 depending on aPos. Will never return 0 as its reserved to mean not yet persistent. */ TInt CDscDatabase::GetNextItemIdL(TDscPosition aPos, const TUid& aDscId) const { RDbView view; CleanupClosePushL(view); RBuf sqlCmd; CleanupClosePushL(sqlCmd); sqlCmd.CreateL(KSqlQueryAllItemIdsLength); sqlCmd.Format(KSqlQueryAllItemIds, &KItemIdCol, &KItemTable,&KDscIdCol, aDscId, &KItemIdCol ); DebugPrint(sqlCmd); User::LeaveIfError(view.Prepare(iDatabase, sqlCmd)); User::LeaveIfError(view.EvaluateAll()); CleanupStack::PopAndDestroy(&sqlCmd); TInt nextId = 1; //add first item with id=1 and reserve 0 to mean "not yet persistent" if (aPos==ELast && view.LastL()) { //add at ELast: pos =max of itemId+1 view.GetL(); nextId = view.ColInt(1); if(KMaxTInt == nextId) { User::Leave(KErrOverflow); } //increase, make sure to not use 0 as itemid in the database nextId = (-1==nextId) ? (nextId+2) : (nextId+1); } else if (aPos==EFirst && view.FirstL()) { //add at EFirst: pos=min of itemId-1 view.GetL(); nextId = view.ColInt(1); if(KMinTInt == nextId) { User::Leave(KErrUnderflow); } //decrease, but reserve 0 to mean "not yet persistent" nextId = (1==nextId) ? (nextId-2) : (nextId-1); } CleanupStack::PopAndDestroy(&view); return nextId; }
// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // EXPORT_C void PosLmLandmarkHandler::ReadLandmarkL( CPosLmLocalDbAccess& aDbAccess, CPosLandmark& aLandmark) { RDbView view; OpenLandmarkViewLC( aLandmark.LandmarkId(), view, aDbAccess ); view.GetL(); ReadLandmarkL( view, aDbAccess, aLandmark ); CleanupStack::PopAndDestroy( &view ); }
void CAlmSettingsSession::ProcessDataL(void) { TInt func=Message().Function(); _LIT(KSQL,"select id,name,cid,value from settings where cid=%u and name='%S'"); RDbView view; TBuf<128> sql; TUint32 cid=CategoryL(Message().Ptr0()); HBufC8* param1=ValueLC(Message().Ptr1()); TPtrC name((const TUint16*)param1->Ptr(),param1->Length()/2); sql.Format(KSQL,cid,&name); User::LeaveIfError(view.Prepare(iServer.DbL(),TDbQuery(sql),(func==ESettingsServerRequestSet)?RDbView::EUpdatable:RDbView::EReadOnly)); CleanupClosePushL(view); User::LeaveIfError(view.EvaluateAll()); TBool first=view.FirstL(); if(func==ESettingsServerRequestSet) { if(first) view.UpdateL(); else view.InsertL(); CleanupCancelPushL(view); if(!first) { view.SetColL(2,name); view.SetColL(3,cid); } HBufC8* value=ValueLC(Message().Ptr2()); view.SetColL(4,*value); view.PutL(); CleanupStack::Pop(); //view cancel CleanupStack::PopAndDestroy(); //value iServer.Notify(); } else { if(!first) User::Leave(KErrNotFound); view.GetL(); TInt len=view.ColSize(4); if(func==ESettingsServerRequestGetData) { HBufC8* data=HBufC8::NewLC(len); TPtr8 ptr(data->Des()); RDbColReadStream stream; stream.OpenLC(view,4); stream.ReadL(ptr,len); Message().WriteL(Message().Ptr2(),ptr); CleanupStack::PopAndDestroy(2); //stream,data } else { TPckgC<TInt> size(len); Message().WriteL(Message().Ptr2(),size); } } CleanupStack::PopAndDestroy(2); //view,param1 }
// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // EXPORT_C void PosLmLandmarkHandler::ReadPartialLandmarkL( CPosLmLocalDbAccess& aDbAccess, CPosLandmark& aLandmark, CPosLmPartialReadParameters& aPartialSettings ) { RDbView view; OpenLandmarkViewLC( aLandmark.LandmarkId(), view, aDbAccess ); view.GetL(); ReadPartialLandmarkL( view, aDbAccess, aLandmark, aPartialSettings ); CleanupStack::PopAndDestroy( &view ); }
TInt CSCPParamDB :: GetValuesForParameterL(TInt aParamID, RPointerArray <HBufC>& aParamValues, const TInt32 aApp) { _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL >>>")); RDbView lDBView; CleanupClosePushL(lDBView); HBufC* lSelectQry = HBufC :: NewLC(KSelectWhereParamIdAppID().Length() + 40); lSelectQry->Des().Format (KSelectWhereParamIdAppID, aParamID, aApp); __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry))); __LEAVE_IF_ERROR(lDBView.EvaluateAll()); if (lDBView.FirstL()) { TInt size(0); TInt lRowCount = lDBView.CountL(); if(lRowCount == 0) { _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter")); CleanupStack :: PopAndDestroy(2); return KErrNotFound; } TInt lErr(KErrNone); do { lDBView.GetL(); size = lDBView.ColDes(iColSet->ColNo(KColValueDes)).Size(); if(size) { HBufC* lBuff = HBufC :: NewL(size); TPtr lPtr(lBuff->Des()); lPtr.Copy(lDBView.ColDes(iColSet->ColNo(KColValueDes))); TRAP(lErr, aParamValues.AppendL(lBuff)); if(lErr != KErrNone) { aParamValues.ResetAndDestroy(); User :: Leave(lErr); } } } while(lDBView.NextL()); } CleanupStack :: PopAndDestroy(2); _SCPDB_LOG(_L("[CSCPParamDB]-> GetValuesForParameterL <<<")); return KErrNone; }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CScheduleDB::ReadDbItemsL(RPointerArray<CMsgSched>& aItemArray) { aItemArray.ResetAndDestroy();// first reset the array TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM "));// just get all columns & rows QueryBuffer.Append(KtxtItemlist); RDbView Myview; Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.EvaluateAll(); Myview.FirstL(); while(Myview.AtRow()) // Just delete one instance of the message { Myview.GetL(); CMsgSched* NewItem = new(ELeave)CMsgSched(); aItemArray.Append(NewItem); NewItem->iIndex = Myview.ColInt32(1); NewItem->iTime = Myview.ColTime(5); NewItem->iRepeat = Myview.ColInt32(6); if(Myview.ColInt32(2) > 50) NewItem->iUnicode = ETrue; else NewItem->iUnicode = EFalse; NewItem->iNunmber = Myview.ColDes(3).AllocL(); NewItem->iMessage = Myview.ColDes(4).AllocL(); if(Myview.ColInt32(7) > 50) NewItem->iEnabled = ETrue; else NewItem->iEnabled = EFalse; if(Myview.ColInt32(8) > 50) NewItem->iFlashSMS = ETrue; else NewItem->iFlashSMS = EFalse; Myview.NextL(); } CleanupStack::PopAndDestroy(1); // Myview }
// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // void PosLmLandmarkHandler::ReadLandmarkL( CPosLmLocalDbAccess& aDbAccess, CPosLandmark& aLandmark, CPosLandmark::TAttributes aAttributes, TBool aHasRequestedFields, const RArray<TUint>& aRequestedFields ) { RDbView view; OpenLandmarkViewLC( aLandmark.LandmarkId(), view, aDbAccess ); view.GetL(); ReadLandmarkL( view, aDbAccess, aLandmark, aAttributes, aHasRequestedFields, aRequestedFields ); CleanupStack::PopAndDestroy( &view ); }
TUint32 CAlmSettingsSession::CategoryL(const TAny* aSrc) { _LIT(KSQL,"select id from categories where name='%S'"); RDbView view; TBuf<128> sql; HBufC8* param0=ValueLC(aSrc); TPtrC name((const TUint16*)param0->Ptr(),param0->Length()/2); sql.Format(KSQL,&name); User::LeaveIfError(view.Prepare(iServer.DbL(),TDbQuery(sql),RDbView::EReadOnly)); CleanupClosePushL(view); User::LeaveIfError(view.EvaluateAll()); if(!view.FirstL()) User::Leave(KErrNotFound); view.GetL(); TUint32 cid=view.ColUint32(1); CleanupStack::PopAndDestroy(2); //view,param1 return cid; }
TInt CSCPParamDB :: ListParamsUsedByAppL(RArray <TInt>& aParamIds, const TInt32 aApp) { _SCPDB_LOG(_L("[CSCPParamDB]-> ListParamsUsedByApp() >>>")); RDbView lDBView; CleanupClosePushL(lDBView); HBufC* lSelectQry(NULL); if(aApp == -1) { lSelectQry = HBufC :: NewLC(KSelectAllAscParamID().Length()); lSelectQry->Des().Append(KSelectAllAscParamID); } else { lSelectQry = HBufC :: NewLC(KSelectWhereAppIdByAscParamID().Length() + 15); lSelectQry->Des().Format(KSelectWhereAppIdByAscParamID, aApp); } _SCPDB_LOG(_L("[CSCPParamDB]-> SQL Query: %S"), &lSelectQry->Des()); _SCPDB_LOG(_L("[CSCPParamDB]-> Executing the query...")); __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(lSelectQry->Des()))); __LEAVE_IF_ERROR(lDBView.EvaluateAll()); TInt lErr(KErrNone); TInt lStatus(KErrNone); TRAP(lErr, lStatus = lDBView.FirstL()); _SCPDB_LOG(_L("[CSCPParamDB]-> Fetching values for the column KColParamId")); if(lErr == KErrNone && lStatus) { do { lDBView.GetL(); TInt lPID = lDBView.ColInt(iColSet->ColNo(KColParamId)); if(aParamIds.Find(lPID) == KErrNotFound) { aParamIds.AppendL(lPID); } } while(lDBView.NextL()); } _SCPDB_LOG(_L("[CSCPParamDB]-> Query execution complete...")); CleanupStack :: PopAndDestroy(2); _SCPDB_LOG(_L("[CSCPParamDB]-> ListParamsUsedByApp() <<<")); return KErrNone; }
TInt CSCPParamDB :: ListEntriesL(RArray <TInt32>& aNumCols, RPointerArray <HBufC>& aDesCols, const TInt32 aApp) { _SCPDB_LOG(_L("[CSCPParamDB]-> ListEntries() >>>")); RDbView lDBView; CleanupClosePushL(lDBView); HBufC* lSelectQry(NULL); if(aApp == -1) { lSelectQry = HBufC :: NewLC(KSelectAll().Length() + 50); lSelectQry->Des().Format(KSelectAll); } else { lSelectQry = HBufC :: NewLC(KSelectWhereAppId().Length() + 30); lSelectQry->Des().Format(KSelectWhereAppId, aApp); } __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry))); __LEAVE_IF_ERROR(lDBView.EvaluateAll()); TInt lRet(KErrNone); TBool lStatus(EFalse); TRAP(lRet, lStatus = lDBView.FirstL()); if(lRet == KErrNone && lStatus) { do { lDBView.GetL(); aNumCols.AppendL(lDBView.ColInt(iColSet->ColNo(KColParamId))); aNumCols.AppendL(lDBView.ColInt(iColSet->ColNo(KColAppId))); aNumCols.AppendL(lDBView.ColInt(iColSet->ColNo(KColValueInt))); TPtrC lValueDes = lDBView.ColDes16(iColSet->ColNo(KColValueDes)); HBufC* lBuff = HBufC :: NewL(lValueDes.Length()); lBuff->Des().Append(lValueDes); aDesCols.AppendL(lBuff); } while(lDBView.NextL()); } _SCPDB_LOG(_L("[CSCPParamDB]-> ListEntries() <<<")); CleanupStack :: PopAndDestroy(2); return KErrNone; }
// ----------------------------------------------------------------------------- // CWPInternetAPDB::DeleteFromDatabaseL // ----------------------------------------------------------------------------- // TBool CWPInternetAPDB::DeleteFromDatabaseL(TUint aAPId) { FLOG( _L( "[Provisioning] CWPInternetAPDB::DeleteFromDatabaseL" ) ); TBool rowsdeleted = EFalse; TFileName QueryBuffer; QueryBuffer.Copy(_L("SELECT * FROM ")); QueryBuffer.Append(KtxtItemlist); QueryBuffer.Append(_L(" WHERE ")); QueryBuffer.Append(NCol2); QueryBuffer.Append(_L(" = ")); QueryBuffer.AppendNum(aAPId); iItemsDatabase.Begin(); RDbView Myview; // query buffer with index finds only the selected item row. Myview.Prepare(iItemsDatabase, TDbQuery(QueryBuffer)); CleanupClosePushL(Myview); Myview.EvaluateAll(); if( Myview.FirstL()) { if (!Myview.IsEmptyL()) { // we have autoincrement in index so it should be unique // but just to make sure, we use 'while', instead of 'if' while (Myview.AtRow()) { Myview.GetL(); Myview.DeleteL(); Myview.NextL(); } iItemsDatabase.Commit(); // compacts the databse, by physically removig deleted data. iItemsDatabase.Compact(); rowsdeleted = ETrue; } } CleanupStack::PopAndDestroy(1); // Myview FLOG( _L( "[Provisioning] CWPInternetAPDB::DeleteFromDatabaseL: done" ) ); return rowsdeleted; }
// ----------------------------------------------------------------------------- // CWPInternetAPDB::DeleteFromDatabaseL // ----------------------------------------------------------------------------- // TBool CSCOMOAdapterDb::DeleteFromDatabaseL(TUint32 aLuid) { TBool rowsdeleted = EFalse; TFileName sqlQuery; PrepareLuidQuery(aLuid, sqlQuery); BeginDatabaseTransaction(); RDbView view; // query buffer with index finds only the selected item row. view.Prepare(iDatabase, TDbQuery(sqlQuery)); CleanupClosePushL(view); view.EvaluateAll(); view.FirstL(); if (!view.IsEmptyL()) { // we have autoincrement in index so it should be unique // but just to make sure, we use 'while', instead of 'if' while (view.AtRow()) { view.GetL(); view.DeleteL(); view.NextL(); } CommitDatabaseTransaction(); // compacts the databse, by physically removig deleted data. iDatabase.Compact(); rowsdeleted = ETrue; } CleanupStack::PopAndDestroy(1); // view return rowsdeleted; }
// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // void PosLmLandmarkHandler::ReadCategoriesL( CPosLmLocalDbAccess& aDbAccess, CPosLandmark& aLandmark) { HBufC* sql = HBufC::NewLC(KPosLmSqlStatementMaxLen); sql->Des().Format(KPosLmSqlFindUint, &KPosLmSqlAll, &KPosLmLandmarkCategoryTable, &KPosLmLandmarkIdCol, aLandmark.LandmarkId()); RDbView view; aDbAccess.PrepareViewLC(CPosLmLocalDbAccess::EUpdatablePreparation, view, *sql); while (view.NextL()) { view.GetL(); aLandmark.AddCategoryL(view.ColUint32(EPosLmLccCategoryIdCol)); } CleanupStack::PopAndDestroy(2, sql); //&view }