public function execute(query:IOLAPQuery):mx.rpc:AsyncToken
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
Queues an OLAP query for execution.
After you call the refresh()
method to update the cube,
you must wait for a complete
event
before you call the execute()
method.
OLAP cubes can be complex, so you do not want your application
to pause while Flex calculates the results of your OLAP query.
The execute()
method returns an instance of the AsyncToken class,
which lets you set up handlers for asynchronous operations so that
your application can continue to execute during query processing.
When using the AsyncToken class, you set up two functions to handle the query results.
In this example, the showResult() function handles the query results when the query succeeds,
and the showFault() function handles any errors detected during query execution:
<mx:Script>
// Function to execute a query.
private function runQuery(cube:IOLAPCube):void {
// Create a query instance.
var query:IOLAPQuery = getQuery(cube);
// Execute the query.
var token:AsyncToken = cube.execute(query);
// Set up handlers for the query results.
token.addResponder(new AsyncResponder(showResult, showFault));
}
// Handle a query fault.
private function showFault(result:FaultEvent, token:Object):void {
Alert.show("Error in query.");
}
// Handle a query success.
private function showResult(result:Object, token:Object):void {
if (!result) {
Alert.show("No results from query.");
return;
}
myOLAPDG.dataProvider= result as OLAPResult;
}
</mx:Script>
<mx:OLAPDataGrid id="myOLAPDG" width="100%" height="100%" />
Parameters
| query:IOLAPQuery — The query to execute, represented by an IOLAPQuery instance.
|
ReturnsRelated API Elements