Query Aliases (Select As)

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Posts: 1
Joined: 20 Oct 2006, 06:17

Query Aliases (Select As)

Postby harkonen » 20 Oct 2006, 06:24

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?

User avatar
Site Admin
Posts: 21930
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 21 Oct 2006, 11:13

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.

Code: Select all


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.
...addicted to flash games
User avatar
Posts: 63
Joined: 11 Jul 2006, 20:52

Postby jflowers45 » 01 Mar 2007, 03:41

just an fyi

i think it has to be

Code: Select all

 var theAverage = tempRow.getItem(0)
How you doin?

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 16 guests