IPreparedQuery query = dataEngine.prepare( queryDefn );  IQueryResults result = query.execute( executionContext .getSharedScope( ) ); IResultIterator iter = result.getResultIterator( ); while ( iter.next( ) )
IPreparedQuery query = dataEngine.prepare(queryDefn);  IQueryResults result = query.execute(executionContext.getSharedScope()); IResultIterator iter = result.getResultIterator(); int count = 0; while (iter.next())
	private Collection createDynamicSelectionChoices( String dataSetName,			String labelStmt, String valueStmt, String dataType )	{		ArrayList choices = new ArrayList( );		ReportDesignHandle report = (ReportDesignHandle) this.runnable				.getDesignHandle( );		DataSetHandle dataSet = report.findDataSet( dataSetName );		if ( dataSet != null )		{			try			{				DataEngine dataEngine = getDataEngine( );				// Define data source and data set				DataSourceHandle dataSource = dataSet.getDataSource( );				try				{					dataEngine							.defineDataSource( ModelDteApiAdapter.getInstance( )									.createDataSourceDesign( dataSource ) );					dataEngine.defineDataSet( ModelDteApiAdapter.getInstance( )							.createDataSetDesign( dataSet ) );				}				catch ( BirtException e )				{					log.log( Level.SEVERE, e.getMessage( ) );				}				ScriptExpression labelExpr = new ScriptExpression( labelStmt );				ScriptExpression valueExpr = new ScriptExpression( valueStmt );				QueryDefinition queryDefn = new QueryDefinition( );				queryDefn.setDataSetName( dataSetName );				// add parameters if have any				Iterator paramIter = dataSet.paramBindingsIterator( );				while ( paramIter.hasNext( ) )				{					ParamBindingHandle binding = (ParamBindingHandle) paramIter							.next( );					String paramName = binding.getParamName( );					String paramExpr = binding.getExpression( );					queryDefn.getInputParamBindings( ).add(							new InputParameterBinding( paramName,									new ScriptExpression( paramExpr ) ) );				}				queryDefn.getRowExpressions( ).add( labelExpr );				queryDefn.getRowExpressions( ).add( valueExpr );				// Create a group to skip all of the duplicate values				GroupDefinition groupDef = new GroupDefinition( );				groupDef.setKeyExpression( valueStmt );				queryDefn.addGroup( groupDef );				IPreparedQuery query = dataEngine.prepare( queryDefn );				IQueryResults result = query.execute( executionContext						.getSharedScope( ) );				IResultIterator iter = result.getResultIterator( );				while ( iter.next( ) )				{					String label = iter.getString( labelExpr );					Object value = iter.getValue( valueExpr );					choices.add( new SelectionChoice( label, convertToType(							value, dataType ) ) );					iter.skipToEnd( 1 ); // Skip all of the duplicate values				}			}			catch ( BirtException ex )			{				ex.printStackTrace( );			}		}		return choices;	}