terminalsecurity/SCP/SCPDatabase/src/SCPParamDB.cpp
changeset 63 e0c1916b8ddc
parent 22 19fb38abab1d
--- a/terminalsecurity/SCP/SCPDatabase/src/SCPParamDB.cpp	Wed Aug 18 10:39:36 2010 +0300
+++ b/terminalsecurity/SCP/SCPDatabase/src/SCPParamDB.cpp	Thu Sep 02 21:22:11 2010 +0300
@@ -177,23 +177,24 @@
 
     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
-    lDBView.FirstL();
+    if( lDBView.FirstL())
+    {
+    	TInt lRowCount = lDBView.CountL();
 
-    TInt lRowCount = lDBView.CountL();
-
-    if(lRowCount == 0) {
+    	if(lRowCount == 0) {
         _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
         CleanupStack :: PopAndDestroy(2);
         return KErrNotFound;
-    }
-    else if(lRowCount > 1) {
+    	}
+    	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));
+    	lDBView.GetL();
+    	aApp = lDBView.ColInt(iColSet->ColNo(KColAppId));
+    	aValue = lDBView.ColInt(iColSet->ColNo(KColValueInt));
+    }
     CleanupStack :: PopAndDestroy(2);
 
     _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL <<<"));
@@ -212,21 +213,20 @@
     __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
     __LEAVE_IF_ERROR(lDBView.EvaluateAll());
     
-    lDBView.FirstL();
-
+    if (lDBView.FirstL())
+    {
+    	TInt size(0);
+    	TInt lRowCount = lDBView.CountL();
 
-    TInt size(0);
-    TInt lRowCount = lDBView.CountL();
-
-    if(lRowCount == 0) {
+    	if(lRowCount == 0) {
         _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
         CleanupStack :: PopAndDestroy(2);
         return KErrNotFound;
-    }
+    	}
     
-    TInt lErr(KErrNone);
+    	TInt lErr(KErrNone);
     
-    do {
+    	do {
         lDBView.GetL();
         size = lDBView.ColDes(iColSet->ColNo(KColValueDes)).Size();
 
@@ -242,8 +242,9 @@
                 User :: Leave(lErr);
             }
         }
+    	}
+    	while(lDBView.NextL());
     }
-    while(lDBView.NextL());
 
     CleanupStack :: PopAndDestroy(2);
     _SCPDB_LOG(_L("[CSCPParamDB]-> GetValuesForParameterL <<<"));