Search code examples
sqliteactionscript-3apache-flexflash-builderflex4.5

Flex SQLite Display SUM() result


I try to display the Total sum() from a sqlStmt but all i got is [object, object], any idea how?

Thanks

private function displayAmountHeading():void  {
        sqlStmt = new SQLStatement();
        sqlStmt.sqlConnection = sqlConn;
        sqlStmt.text = "SELECT SUM(Amount) FROM MainTable";
        sqlStmt.execute();
        var result:Array = sqlStmt.getResult().data;
        if (result != null) trace(result);
      }

//return [object, object]

Solution

  • You're attempting to trace an array. If you want to see the first value in that array, try

    SELECT SUM(Amount) as sum FROM MainTable
    
    trace(result[0].sum);