Having an issue with a select statement:
var sql = "SELECT AVG(total) AS averageTotal FROM Table"
var queryRes = dbase.executeQuery(sql);
var tempRow = queryRes.get(0);
var theAverage = tempRow.getItem("averageTotal")
theAverage returns null.
I can do a select that returns 1 numeric result without any problem. However, I cannot do an aliased result set in any way I have tried.
Any suggestions or thoughts?
HK
Query Aliases (Select As)
I didn't have time to test the problem yet but I can suggest a couple of tests:
1 -> trace the size of the returned array.
what does it say?
2-> Try calling the executeQuery method like this:
This will return an array of rows, where each row is indexed by numbers starting from index 1.
So now you can get the value like this:
1 -> trace the size of the returned array.
Code: Select all
trace(queryRes.size())
what does it say?
2-> Try calling the executeQuery method like this:
Code: Select all
_server.executeQuery(theSql, _server.QUERY_INT_KEYS)
This will return an array of rows, where each row is indexed by numbers starting from index 1.
So now you can get the value like this:
Code: Select all
var theAverage = tempRow.getItem(1)
Last edited by Lapo on 09 Dec 2008, 08:19, edited 1 time in total.
- jflowers45
- Posts: 63
- Joined: 11 Jul 2006, 20:52
Return to “Server Side Extension Development”
Who is online
Users browsing this forum: No registered users and 41 guests