必ず:
- 聞く
SQLEvent.RESULT
- クエリを実行する
- 結果を処理する
selectStmt = new SQLStatement();
selectStmt.sqlConnection = conn;
selectStmt.text="SELECT name, level, score FROM highscores WHERE ROWID <=5 ORDER BY score DESC";
// Create a listener in order to process the results
var resultHandler:Function = function(event:SQLEvent):void {
selectStmt.removeEventListener(SQLEvent.RESULT, resultHandler);
// Get the result
var result:SQLResult = dbStatement.getResult();
if (result != null) {
// Iterate through each entries
for each (var entry:Object in result.data) {
// Trace entry
trace(entry.name, entry.level, entry.score);
}
}
};
// Add a listener in order to read the results when the request will be done
selectStmt.addEventListener(SQLEvent.RESULT, resultHandler);
selectStmt.execute();