Skip to main content



      Home
Home » Archived » BIRT » Union Between Multiple DataSets
Union Between Multiple DataSets [message #207000] Mon, 18 December 2006 07:56 Go to next message
Eclipse UserFriend
Originally posted by: leonardo.pinho.gmail.com

Hi All,

I'd like to know if it`s possible did the union between two or more
datasets. I can't do this using sql query because the data belong to
differents datasets.

Thanks in advance,
Leo
Re: Union Between Multiple DataSets [message #207008 is a reply to message #207000] Mon, 18 December 2006 07:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: leonardo.pinho.gmail.com

sorry... I made a mistake...

"... I can't do this using sql query because the data belong to differents
DATASOURCES."
Re: Union Between Multiple DataSets [message #207127 is a reply to message #207008] Mon, 18 December 2006 14:47 Go to previous messageGo to next message
Eclipse UserFriend
The Joined data set allows combining datasets with left/right inner/outer
joins.

Jason

"Leonardo Pinho" <leonardo.pinho@gmail.com> wrote in message
news:20b3b838d3dbfca03feacb1375c3807c$1@www.eclipse.org...
> sorry... I made a mistake...
>
> "... I can't do this using sql query because the data belong to differents
> DATASOURCES."
>
>
>
Re: Union Between Multiple DataSets [message #207241 is a reply to message #207127] Tue, 19 December 2006 05:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: leonardo.pinho.gmail.com

Yes, I know it but joined data set doesn`t solve my problem... because I
need a union relationship. For example:

- DatasetA / DatasourceA:
select columnA1, columnA2 from tableA

- DatasetB / DatasourceB:
select columnB1, columnB2 from tableB

And I'd would to make a single dataset with the results from datasetA plus
the results from datasetB, like the sql query:

"select columnA1, columnA2 from tableA
UNION
select columnB1, columnB2 from tableB"

But I can't do this sql query because I have two differents datasources...

Do you have other idea?

Thanks again,
Leo
Re: Union Between Multiple DataSets [message #207327 is a reply to message #207241] Tue, 19 December 2006 10:26 Go to previous messageGo to next message
Eclipse UserFriend
The only idea that I can think of is using a scripted data set and building
the union yourself.
This would probably be best done in a Java class and called from the
Scripted Data set.
Also you may want to log an enhancement to support UNION in the Joined Data
Set.

Jason


"Leonardo Pinho" <leonardo.pinho@gmail.com> wrote in message
news:13a6d6abd13021c4d04b415983a070a3$1@www.eclipse.org...
> Yes, I know it but joined data set doesn`t solve my problem... because I
> need a union relationship. For example:
>
> - DatasetA / DatasourceA:
> select columnA1, columnA2 from tableA
>
> - DatasetB / DatasourceB:
> select columnB1, columnB2 from tableB
>
> And I'd would to make a single dataset with the results from datasetA plus
> the results from datasetB, like the sql query:
>
> "select columnA1, columnA2 from tableA
> UNION
> select columnB1, columnB2 from tableB"
>
> But I can't do this sql query because I have two differents datasources...
>
> Do you have other idea?
>
> Thanks again,
> Leo
>
Re: Union Between Multiple DataSets [message #209181 is a reply to message #207327] Thu, 04 January 2007 13:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: leonardo.pinho.gmail.com

Do you know how I can access the results of a dataset using the Report
API? I'm afraid that`s not possible...

Thanks again!
Re: Union Between Multiple DataSets [message #209811 is a reply to message #209181] Mon, 08 January 2007 10:46 Go to previous message
Eclipse UserFriend
This is a somewhat crude example of using the data engine api.
You could also add a table and set the visibility to hide and use the data
exatract task.

Jason


import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.data.engine.api.DataEngine;
import org.eclipse.birt.data.engine.api.DataEngineContext;
import org.eclipse.birt.data.engine.api.IPreparedQuery;
import org.eclipse.birt.data.engine.api.IQueryResults;
import org.eclipse.birt.data.engine.api.IResultIterator;
import org.eclipse.birt.data.engine.api.IResultMetaData;
import org.eclipse.birt.data.engine.api.querydefn.OdaDataSetDesign;
import org.eclipse.birt.data.engine.api.querydefn.OdaDataSourceDesi gn;
import org.eclipse.birt.data.engine.api.querydefn.QueryDefinition;
import org.eclipse.birt.report.model.api.DesignConfig;
import org.eclipse.birt.report.model.api.IDesignEngine;
import org.eclipse.birt.report.model.api.IDesignEngineFactory;
import org.eclipse.birt.report.model.api.OdaDataSetHandle;
import org.eclipse.birt.report.model.api.OdaDataSourceHandle;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import org.eclipse.birt.report.model.api.SessionHandle;

import com.ibm.icu.util.ULocale;
/**
* Simple BIRT Design Engine API (DEAPI) demo.
*/

public class DataEngineExample {


public static void main( String[] args )
{
try
{
extract( );
}
catch ( Exception e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}

}

// This function shows how to build a very simple BIRT report with a
// minimal set of content: a simple grid with an image and a label.

static void extract( ) throws Exception
{







//Configure the Engine and start the Platform
DesignConfig config = new DesignConfig( );

config.setProperty("BIRT_HOME",
"C:/birt-runtime-2_1_1/birt-runtime-2_1_1/ReportEngine");
IDesignEngine engine = null;
try{


Platform.startup( config );
IDesignEngineFactory factory = (IDesignEngineFactory) Platform
.createFactoryObject(
IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
engine = factory.createDesignEngine( config );

}catch( Exception ex){
ex.printStackTrace();
}


SessionHandle session = engine.newSessionHandle( ULocale.ENGLISH ) ;

// Create a new report design.

ReportDesignHandle design =
session.openDesign("c:/tmp/dataextract.rptdesign");

OdaDataSourceHandle sourceHandle = (OdaDataSourceHandle)
design.findDataSource( "Data Source" );
OdaDataSetHandle dsh = (OdaDataSetHandle)design.findDataSet("dataset");



OdaDataSourceDesign odaDataSource;


DataEngine de=null;

//config.setRourcePath()

de = DataEngine.newDataEngine( DataEngineContext.newInstance(
DataEngineContext.DIRECT_PRESENTATION,
null,
null,
null ) );



odaDataSource = new OdaDataSourceDesign( "Test Data Source" );
odaDataSource.setExtensionID( "org.eclipse.birt.report.data.oda.jdbc" );
odaDataSource.addPublicProperty( "odaURL",
sourceHandle.getProperty("odaURL").toString() );
odaDataSource.addPublicProperty( "odaDriverClass",
sourceHandle.getProperty("odaDriverClass").toString());
odaDataSource.addPublicProperty( "odaUser",
sourceHandle.getProperty("odaUser").toString() );
odaDataSource.addPublicProperty( "odaPassword", "" );

OdaDataSetDesign odaDataSet = new OdaDataSetDesign( "Test Data Set" );
odaDataSet.setDataSource( odaDataSource.getName( ) );
odaDataSet.setExtensionID(
"org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
odaDataSet.setQueryText( dsh.getQueryText() );

de.defineDataSource( odaDataSource );
de.defineDataSet( odaDataSet );

QueryDefinition queryDefinition = new QueryDefinition( );
queryDefinition.setDataSetName( odaDataSet.getName() );
queryDefinition.setAutoBinding(true);


IPreparedQuery pq = de.prepare( queryDefinition );

IQueryResults qr = pq.execute( null );



IResultIterator ri = qr.getResultIterator( );
int cc = ri.getResultMetaData().getColumnCount();
IResultMetaData rsmd = ri.getResultMetaData();


while ( ri.next( ) )
{


for ( int i = 0; i < cc; i++ )
System.out.print(ri.getValue(rsmd.getColumnName(i+1)) + " ");

System.out.println("");
}

ri.close( );
qr.close( );
de.shutdown( );






System.out.println("Finished");

// We're done!
}
}

"Leonardo Pinho" <leonardo.pinho@gmail.com> wrote in message
news:fe1c154da9bd4c88712905ab1e87f298$1@www.eclipse.org...
> Do you know how I can access the results of a dataset using the Report
> API? I'm afraid that`s not possible...
>
> Thanks again!
>
Previous Topic:Localization problem
Next Topic:BirtException: $NO-RB$ Can't startup the OSGI framework
Goto Forum:
  


Current Time: Wed Jun 18 17:16:55 EDT 2025

Powered by FUDForum. Page generated in 0.04217 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top