예제 #1
0
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
}
예제 #2
0
//Read aItem from DSC DB either by fileName, argList and dscId, or by itemId and dscId	
void CDscDatabase::ReadItemL(CDscItem& aItem)
	{
	//Leave if DB is opened for enumeration	
	if (iIsEnumOpened)
		{
		User::Leave(KErrLocked);
		}
		
	DatabaseBeginLC();	

	RDbView view;
	CleanupClosePushL(view);
	
	QueryItemL(view,  aItem);
	if(view.CountL()==0)
		{
		 //aItem does not exist
		User::Leave(KErrNotFound);	
		}
	else
		{
		view.FirstL(); 
		ReadDscItemL(view, aItem);
		}
	
	CleanupStack::PopAndDestroy(2); //view and CleanupDatabaseRollback
	}
예제 #3
0
void InsertCategoryTableL()
	{
	RDbView view;
	TInt err = view.Prepare(TheDatabase, _L("select * from CATEGORY"), view.EInsertOnly);
	TEST2(err, KErrNone);
	TheRowSet = view;	

	CDbColSet* colSet = TheRowSet.ColSetL();
	const TInt KCategoryIdIdx = colSet->ColNo(KCategoryId);
	const TInt KCategoryNameIdx = colSet->ColNo(KCategoryName);
	const TInt KGenreIdx = colSet->ColNo(KGenre);
	delete colSet;

	err = TheDatabase.Begin();
	TEST2(err, KErrNone);

	for (TInt ii=1;ii<=KCategoryRecordCount;++ii)
		{
		TheRowSet.InsertL();
		TheRowSet.SetColL(KCategoryIdIdx, ii);
		TheRowSet.SetColL(KCategoryNameIdx, _L("History"));
		TheRowSet.SetColL(KGenreIdx,(ii*500));
		TheRowSet.PutL();
		}

	err = TheDatabase.Commit();
	TEST2(err, KErrNone);
	
	//err = TheDatabase.Compact();
	//TEST2(err, KErrNone);

	TheRowSet.Close();	
	}
예제 #4
0
TBool CSCPParamDB :: IsParamValueSharedL(HBufC* aParamValue, const TInt32 aApp) {
    _SCPDB_LOG(_L("[CSCPParamDB]-> IsParamValueShared >>>"));
    
    if(aParamValue == NULL) {
        return KErrArgument;
    }
    
    RDbView lDBView;
    CleanupClosePushL(lDBView);
    
    HBufC* lSelectQry  = HBufC :: NewLC(KSelectAppIDParamValNotIn().Length() + aParamValue->Des().Length() + 50);
    lSelectQry->Des().Format(KSelectAppIDParamValNotIn, aApp, &aParamValue->Des());
    
    __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
    __LEAVE_IF_ERROR(lDBView.EvaluateAll());
    
    TInt lRowCnt(0);
    TInt lStatus(KErrNone);
    
    TRAP(lStatus, lRowCnt = lDBView.CountL());
    
    if(lStatus != KErrNone) {
        _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: Unable to determine row count..."));    
    }
    else {
        if(lRowCnt > 0) {
            CleanupStack :: PopAndDestroy(2);
            return ETrue;
        }
    }
    
    _SCPDB_LOG(_L("[CSCPParamDB]-> IsParamValueShared <<<"));
    CleanupStack :: PopAndDestroy(2);
    return EFalse;
}
// -----------------------------------------------------------------------------
// 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
    }
예제 #7
0
//Query the aItem from Table DscItem	
void CDscDatabase::QueryItemL(RDbView& aView, const CDscItem& aItem) const
	{
	RBuf sqlCmd;
	CleanupClosePushL(sqlCmd);
	
	if (aItem.ItemId())
		{
		sqlCmd.CreateL(KSqlSelectDscItemOnIdLength);
		sqlCmd.Format(	KSqlSelectDscItemOnId, &KDscIdCol, &KItemIdCol, &KFileNameCol, 
						&KArgListCol,&KStartMethodCol, &KTimeoutCol, &KNoOfRetriesCol, 
						&KMonitorCol, &KStartupTypeCol, &KViewlessCol, &KStartInBackgroundCol, 
						&KItemTable, &KDscIdCol, aItem.DscId(), &KItemIdCol, aItem.ItemId());
		}
	else 
		{
		const TPtrC filename = aItem.FileName();
		const TPtrC argList = aItem.Args();	//whitespace already trimmed
		
		LeaveIfFileParamsNotValidL(aItem);
			
		const TInt length = KSqlSelectDscItemOnNameLength + filename.Length() + argList.Length();
		sqlCmd.CreateL(length);
		sqlCmd.Format(KSqlSelectDscItemOnName, &KDscIdCol, &KItemIdCol, &KFileNameCol,&KArgListCol, &KStartMethodCol, 
					 &KTimeoutCol, &KNoOfRetriesCol, &KMonitorCol, &KStartupTypeCol, &KViewlessCol, &KStartInBackgroundCol, 
					 &KItemTable, &KDscIdCol, aItem.DscId(), &KFileNameCol, &filename, &KArgListCol, &argList);
		}

	DebugPrint(sqlCmd);
	
	User::LeaveIfError(aView.Prepare(iDatabase, sqlCmd));
	User::LeaveIfError(aView.EvaluateAll());  //no error for non existing item
	CleanupStack::PopAndDestroy(&sqlCmd);	
	}
예제 #8
0
// --------------------------------
// CNSmlRoamTable::IsNewItemL( RDbView& aView, TInt aProfileId)
// Checks if whether profile has IAPs
// --------------------------------
//
TBool CNSmlRoamTable::IsNewItemL( RDbView& aView, TInt aProfileId)
	{
	TBuf<KNSmlMaxSQLLength> sqlBuf;
	sqlBuf.Format(KSQLMultiQuery, aProfileId);

	aView.Prepare(iDatabase, TDbQuery( sqlBuf ));
	aView.EvaluateAll();
	return aView.IsEmptyL();
	}
예제 #9
0
// --------------------------------
// CNSmlRoamTable::IsNewItemL( RDbView& aView, CNSmlRoamItem& aItem)
// Checks if whether IAP is new for profile id and priority
// --------------------------------
//
TBool CNSmlRoamTable::IsNewItemL( RDbView& aView, CNSmlRoamItem& aItem)
	{
	TBuf<KNSmlMaxSQLLength> sqlBuf;
	sqlBuf.Format( KSQLSelectUint, aItem.iProfileId, aItem.iPriority );

	aView.Prepare(iDatabase, TDbQuery( sqlBuf ));
	aView.EvaluateAll();
	return aView.IsEmptyL();
	}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
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 );
    }
예제 #11
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
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;
}
예제 #12
0
//This test checks how RDbDatabase::Commit() works if there are some active RDbRowSet objects - 
//read-only and updatable. The expectation is that the Commit() call won't fail, the RDbRowSet objects
//retain their pre-commit positions.
void CommitTestL()
	{
	//Create 2 test tables, insert some records in the first table
	TheDatabase.Close();
	TInt err = TheDatabase.Replace(TheFs, TheDatabaseFileName);
	TEST2(err, KErrNone);
	err = TheDatabase.Execute(_L("CREATE TABLE AA1(Id INTEGER)"));
	TEST2(err, KErrNone);
	err = TheDatabase.Execute(_L("CREATE TABLE AA2(Id INTEGER)"));
	TEST2(err, KErrNone);
	err = TheDatabase.Execute(_L("INSERT INTO AA1(Id) VALUES(1)"));
	TEST2(err, 1);
	err = TheDatabase.Execute(_L("INSERT INTO AA1(Id) VALUES(2)"));
	TEST2(err, 1);
	err = TheDatabase.Execute(_L("INSERT INTO AA1(Id) VALUES(3)"));
	TEST2(err, 1);
	//Begin transaction
	err = TheDatabase.Begin();
	TEST2(err, KErrNone);
	//Prepare read-only view and call FirstL() (TheRowSet object)
	RDbView view;
	err = view.Prepare(TheDatabase, _L("select * from AA1"), RDbRowSet::EReadOnly);
	TEST2(err, KErrNone);
	TheRowSet = view;
	err = view.EvaluateAll();	//DBMS can use FirstL() without the EvaluateAll() call in this case
	TEST2(err, KErrNone);
	TBool rc = TheRowSet.FirstL();
	TEST(rc);
	//Prepare updatable view and call NextL() (TheRowSet2 object)
	err = view.Prepare(TheDatabase, _L("select * from AA1"), RDbRowSet::EUpdatable);
	TEST2(err, KErrNone);
	TheRowSet2 = view;
	err = view.EvaluateAll();	//DBMS can use NextL() without the EvaluateAll() call in this case
	TEST2(err, KErrNone);
	rc = TheRowSet2.FirstL();
	TEST(rc);
	rc = TheRowSet2.NextL();
	TEST(rc);
	//Execute one INSERT statement
	err = TheDatabase.Execute(_L("INSERT INTO AA2(Id) VALUES(1)"));
	TEST2(err, 1);
	//Commit transaction
	err = TheDatabase.Commit();
	TEST2(err, KErrNone);
	//Check the retrieved by TheRowSet record 
	TheRowSet.GetL();
	TEST2(TheRowSet.ColInt(1), 1);
	//Check the retrieved by TheRowSet2 record 
	TheRowSet2.GetL();
	TEST2(TheRowSet2.ColInt(1), 2);
	//Cleanup
	TheRowSet2.Close();
	TheRowSet.Close();
	TheDatabase.Close();
	}
예제 #13
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/ 
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
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
void PosLmLandmarkHandler::UpdateIconAndBasicLandmarkInfoL(
    CPosLmLocalDbAccess& aDbAccess,
    const CPosLandmark& aLandmark,
    const CPosLandmark& aOldLandmark)
    {
    if (!CheckIfIconAndBasicInfoAreEqualL(aLandmark, aOldLandmark))
        {
        TUint32 oldIconId;
        TBool oldIconExists = ReadIconPathIdL(aDbAccess, aLandmark.LandmarkId(),
            oldIconId);

        TPtrC path;
        TInt iconIndex;
        TInt maskIndex;
        TUint32 iconId = 0;

        if (aLandmark.GetIcon(path, iconIndex, maskIndex) == KErrNone)
            {
            PosLmIconHandler::GetIconPathIdL(aDbAccess, path, iconId);
            }

        HBufC* sql = HBufC::NewLC(KPosLmSqlStatementMaxLen);
        sql->Des().Format(KPosLmSqlFindUint, &KPosLmSqlAll,
            &KPosLmLandmarkTable, &KPosLmLandmarkIdCol, aLandmark.LandmarkId());

        RDbView view;
        aDbAccess.PrepareViewLC(CPosLmLocalDbAccess::EUpdatablePreparation,
            view, *sql);

        if (view.NextL())
            {
            view.UpdateL();

            SetIconL(view, aLandmark, iconId);
            SetPositionL(view, aLandmark);
            SetCoverageRadiusL(view, aLandmark);
            SetLandmarkNameL(view, aLandmark);
            SetLandmarkDescriptionL(view, aLandmark);

            view.PutL();
            }
        else
            {
            User::Leave(KErrNotFound);
            }

        CleanupStack::PopAndDestroy(2, sql); //&view

        if (oldIconExists)
            {
            PosLmIconHandler::RemoveIconIfNotUsedL(aDbAccess, oldIconId);
            }
        }
    }
예제 #15
0
//Check the existance of aItem
TBool CDscDatabase::ItemExistsL( const CDscItem& aItem) const
	{
	RDbView view;
	CleanupClosePushL(view);

	QueryItemL(view, aItem);
	const TBool itemExists = !view.IsEmptyL();

	CleanupStack::PopAndDestroy(&view);  
	return (itemExists);
	}
예제 #16
0
// ---------------------------------------------------------------------------
// CLbtDbOperationAO::ExecuteSyncQuery
// ---------------------------------------------------------------------------
//
TInt CLbtDbOperationAO::ExecuteSyncQuery(
    RDbView& aView,
    TDesC& aQuery)
{
    FUNC_ENTER("CLbtDbOperationAO::ExecuteSyncQuery");
    TInt err = aView.Prepare( iDb, TDbQuery(aQuery, EDbCompareFolded),KDbUnlimitedWindow );
    // This should evaluate the query fully
    if ( err == KErrNone )
    {
        err = aView.EvaluateAll();
    }
    return err;
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
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 );
    }
예제 #18
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/ 
void CScheduleDB::UpdateDatabaseL(CMsgStored* aData)
{	
	if(aData)
	{
		TFileName QueryBuffer;
		QueryBuffer.Copy(_L("SELECT * FROM "));
		QueryBuffer.Append(KtxtItemlist2);
		QueryBuffer.Append(_L(" WHERE "));
		QueryBuffer.Append(NCol0);
		QueryBuffer.Append(_L(" = "));
		QueryBuffer.AppendNum(aData->iIndex);

		iItemsDatabase.Begin();
		
		RDbView Myview;
		Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer));
		CleanupClosePushL(Myview);
		
		Myview.EvaluateAll();
		Myview.FirstL();
		
		if(Myview.AtRow())            
		{			
			Myview.UpdateL();

		    if(aData->iMessage)
		    	Myview.SetColL(2,*aData->iMessage);

			Myview.PutL();
		}
				
		CleanupStack::PopAndDestroy(1); // Myview
		iItemsDatabase.Commit();
	}
}
예제 #19
0
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;
}
예제 #20
0
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);
	}
void CSCOMOAdapterDb::UpdateRetryCountForLuidL(TInt aLuid, TInt aRetryCount)
{
	TFileName sqlQuery;
	
	PrepareLuidQuery(aLuid, sqlQuery);
	
	BeginDatabaseTransaction();
	
	RDbView view;
	view.Prepare(iDatabase, TDbQuery(sqlQuery));
	CleanupClosePushL(view);
	
	view.EvaluateAll();
	view.FirstL();
	
	if(view.AtRow())            
	{			
		view.UpdateL();
		view.SetColL(7, aRetryCount);		
		view.PutL();
	}
			
	CleanupStack::PopAndDestroy(1); // view
	
    CommitDatabaseTransaction();
}
예제 #22
0
// ---------------------------------------------------------------------------
// 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
    }
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;    
    
}
예제 #24
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/ 
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();
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
void PosLmLandmarkHandler::SetCoverageRadiusL(
    RDbView& aView,
    const CPosLandmark& aLandmark)
    {
    TReal32 covRadius;

    if (aLandmark.GetCoverageRadius(covRadius) == KErrNone)
        {
        aView.SetColL(EPosLmLcCoverageRadiusCol, covRadius);
        }
    else
        {
        aView.SetColNullL(EPosLmLcCoverageRadiusCol);
        }
    }
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
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 );
    }
예제 #27
0
TInt E32Main()
    {
	__UHEAP_MARK;
	CTrapCleanup* tc = CTrapCleanup::New();
	TEST(tc != NULL);

	TInt err = TheDbs.Connect();
	TEST2(err, KErrNone);

	TBuf<32> format;
	TheTest.Printf(_L("Open database\n"));
	format.Copy(KSecure);
	format.Append(KSecureDbUid.Name());
	err = TheDb.Open(TheDbs, KDbName, format);
	TEST2(err, KErrNone);

	TRAP(err, DoTestL());
	TEST2(err, KErrNone);

	TheView.Close();
	TheTbl.Close();
	TheDb.Close();
	TheDbs.Close();

	TheTest.End();
	TheTest.Close();

	delete tc;

	__UHEAP_MARKEND;
	User::Heap().Check();
	return KErrNone;
    }
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
void PosLmLandmarkHandler::InsertFieldL(
    RDbView& view,
    const TPositionFieldId& aFieldId,
    const CPosLandmark& aLandmark)
    {
    TPtrC fieldValue;

    User::LeaveIfError(aLandmark.GetPositionField(aFieldId, fieldValue));

    view.InsertL();
    view.SetColL(EPosLmLfcLandmarkIdCol, aLandmark.LandmarkId());
    view.SetColL(EPosLmLfcFieldTypeCol, (TUint)aFieldId);
    PosLmLongTextColHandler::WriteToLongTextColumnL(fieldValue, view,
        EPosLmLfcFieldStringCol);
    view.PutL();
    }
예제 #29
0
static void CleanupTest()
	{
	TheView.Close();
	TheTbl.Close();
	TheDb.Close();
	TDBSCUtils::DeleteDatabase(TheDbs, KSecureDbUid, KDbName);
	TheDbs.Close();
	}
예제 #30
0
/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
TInt CExPolicy_Server::UpdateStatusL(TBool& aValue, TBool aProtect)
{	
	TInt ErrRet(KErrNone);
	
	TRAP(ErrRet,
	DeleteStatusInfoL();

	if(aProtect)
	{
		iProtectStatus = aValue;
	}
	else
	{
		iScreenStatus = aValue;
	}

	TFileName QueryBuffer;
	QueryBuffer.Copy(_L("SELECT * FROM "));
	QueryBuffer.Append(KtxtStatuslist);
	
	iItemsDatabase.Begin();
	
	RDbView Myview;
	Myview.Prepare(iItemsDatabase,TDbQuery(QueryBuffer));
	CleanupClosePushL(Myview);
	
	Myview.EvaluateAll();
	Myview.FirstL();
	
	Myview.InsertL(); 
		
	if(iProtectStatus)
		Myview.SetColL(2,0x100);
	else
		Myview.SetColL(2,0x000);
	
	if(iScreenStatus)
		Myview.SetColL(3,0x100);
	else
		Myview.SetColL(3,0x000);

	Myview.PutL(); 
			
	CleanupStack::PopAndDestroy(1); // Myview
	iItemsDatabase.Commit();
	);