mpserviceplugins/mpxsqlitedbcommon/src/mpxdbtable.cpp
changeset 22 ecf06a08d4d9
parent 19 4e84c994a771
child 47 4cc1412daed0
--- a/mpserviceplugins/mpxsqlitedbcommon/src/mpxdbtable.cpp	Fri Apr 16 14:56:30 2010 +0300
+++ b/mpserviceplugins/mpxsqlitedbcommon/src/mpxdbtable.cpp	Mon May 03 12:29:20 2010 +0300
@@ -764,6 +764,41 @@
     }
 
 // ----------------------------------------------------------------------------
+// CMPXDbTable::ExecuteSumExQueryL
+// ----------------------------------------------------------------------------
+//
+EXPORT_C TInt CMPXDbTable::ExecuteSumExQueryL(
+    const TDesC& aQuery, 
+    TUint32 aPlaylistId, 
+    TInt aDrive)
+    {
+    MPX_FUNC("CMPXDbTable::ExecuteSumExQueryL");
+
+    HBufC* query = HBufC::NewLC(aQuery.Length() + KMCIntegerLen);
+    query->Des().Format(aQuery, aPlaylistId);  
+
+    RSqlStatement recordset(iDbManager.ExecuteSelectQueryOnAllDrivesL(aDrive, *query));
+    CleanupClosePushL(recordset);
+
+    TInt sum(0);
+    TInt err(KErrNone);
+    while ((err = recordset.Next()) == KSqlAtRow)
+        {
+        sum += recordset.ColumnInt64(KMPXTableDefaultIndex);
+        }
+    
+    CleanupStack::PopAndDestroy(&recordset);
+    CleanupStack::PopAndDestroy(query);
+
+    if (err != KSqlAtEnd)
+        {
+        User::Leave(KErrCorrupt);
+        }
+
+    return sum;
+    }
+
+// ----------------------------------------------------------------------------
 // CMPXDbTable::ExecuteMediaQueryL
 // ----------------------------------------------------------------------------
 //