Query Aliases (Select As)

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

Moderators: Lapo, Bax

Post Reply
harkonen
Posts: 1
Joined: 20 Oct 2006, 06:17

Query Aliases (Select As)

Post by harkonen »

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
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

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

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.
Lapo
--
gotoAndPlay()
...addicted to flash games
jflowers45
Posts: 63
Joined: 11 Jul 2006, 20:52

Post by jflowers45 »

just an fyi

i think it has to be

Code: Select all

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