简体   繁体   English

Flex SQLite显示SUM()结果

[英]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? 我尝试从sqlStmt显示总和(),但我得到的是[对象,对象],任何想法如何?

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]

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);

The object,object is the string representation of the object, without a toString() method. 对象,object是对象的字符串表示,没有toString()方法。 Use trace(ObjectUtil.toString(result)); 使用trace(ObjectUtil.toString(result)); If your new to the flex sqlStatement you should also read this and this for more information about the return type of the sqlStatement and how to access properties of the result object, when using aggregate functions such as SUM , where u should use aliases, such as SUM(Amount) as sumAmount to later access the property, like resultObject["sumAmount"] or resultObject.sumAmount 如果您的新到柔性的SQLStatement你也应该阅读有关的SQLStatement的返回类型,以及如何访问结果对象,使用聚合函数,如SUM,其中u应该使用别名,比如当属性的详细信息SUM(Amount)作为sumAmount以便以后访问该属性,如resultObject [“sumAmount”]或resultObject.sumAmount

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM