Bug 200144 Exception occurs when nested table share the parent table's result set.[0005]
Description: Exception occurs when nested table share the parent table's result set.[0005] Build number: 2.2.1.v20070816-0630 Steps to reproduce: 1, New a table1 with one binding 2, Insert another table into table1 and share the table1's resultset 3, Preview Actual result: Exception occurs when preview Error log: org.eclipse.birt.report.service.api.ReportServiceException: Error happened while running the report; nested exception is: java.lang.IllegalStateException: forward reference dataset org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder$QueryBuilderVisitor.createQuery(ReportQueryBuilder.java:912) org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder$QueryBuilderVisitor.visitTableItem(ReportQueryBuilder.java:609) org.eclipse.birt.report.engine.ir.TableItemDesign.accept(TableItemDesign.java:44) org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder.build(ReportQueryBuilder.java:246) org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder$QueryBuilderVisitor.visitCell(ReportQueryBuilder.java:806) org.eclipse.birt.report.engine.ir.CellDesign.accept(CellDesign.java:156) org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder.build(ReportQueryBuilder.java:246) org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder$QueryBuilderVisitor.visitRow(ReportQueryBuilder.java:792) org.eclipse.birt.report.engine.ir.RowDesign.accept(RowDesign.java:100) org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder.build(ReportQueryBuilder.java:246) org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder$QueryBuilderVisitor.handleListingBand(ReportQueryBuilder.java:705) org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder$QueryBuilderVisitor.visitTableItem(ReportQueryBuilder.java:641) org.eclipse.birt.report.engine.ir.TableItemDesign.accept(TableItemDesign.java:44) org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder.build(ReportQueryBuilder.java:246) org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder.build(ReportQueryBuilder.java:228) org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.prepare(AbstractDataEngine.java:136) org.eclipse.birt.report.engine.executor.ReportExecutor.execute(ReportExecutor.java:94) org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportExecutor.execute(WrappedReportExecutor.java:59) org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplciateReportExecutor.execute(SuppressDuplciateReportExecutor.java:50) org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportExecutor.execute(WrappedReportExecutor.java:59) org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:138)
data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/api/APITestCase.java
};
			sortDefn[0].setColumn( "SORT_COL3" );
			sortDefn[0].setSortDirection( ISortDefinition.SORT_ASC );
			bindingNameRow = new String[4];
			bindingNameRow[0] = "ROW_COL0";
			bindingNameRow[1] = "ROW_COL1";
			bindingNameRow[2] = "ROW_COL2";
			bindingNameRow[3] = "ROW_COL3";
			
			expressions = new BaseExpression[]{
					new ScriptExpression( "dataSetRow.COL0", 0 ),
					new ScriptExpression( "dataSetRow.COL1", 0 ),
					new ScriptExpression( "dataSetRow.COL2", 0 ),
					new ScriptExpression( "dataSetRow.COL3", 0 )
			};
			
            return this.getQueryDefinition(bindingNameGroup, bindingExprGroup,
					groupDefn, bindingNameSort, bindingExprSort, sortDefn,
					null,null,null,
					bindingNameRow, expressions, dataSetName);
		}
		
		private QueryDefinition getQueryDefinition(String[] bindingNameGroup,
				IBaseExpression[] bindingExprGroup, GroupDefinition[] groupDefn,
				String[] bindingNameSort, IBaseExpression[] bindingExprSort,
				SortDefinition[] sortDefn, String[] bindingNameFilter,
				IBaseExpression[] bindingExprFilter, FilterDefinition[] filterDefn,
				String[] bindingNameRow, IBaseExpression[] bindingExprRow, String dataSetName )
		{
			QueryDefinition queryDefn = new QueryDefinition();