Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Parameters(Parameters)
Parameters [message #714067] Tue, 09 August 2011 18:13 Go to next message
marc.marshall is currently offline marc.marshallFriend
Messages: 30
Registered: June 2011
Member
I have created a Web project that uses Java to build a Birt Report. I am using the OdaDataSourceHandle and OdaDataSetHandle to retrieve my data. I have placed a prepared statement in the setQueryText(sql) of my OdaDataSetHandle. When I run my report I get a Parameter 1 could not be found error. For the life of me I am unable to get the Parameter 1 populated with a value. Does anyone know how I can populate the Parameter 1 in Java Code?

Thanks for the help and your time in advance,

Marc
Re: Parameters [message #714073 is a reply to message #714067] Tue, 09 August 2011 18:33 Go to previous messageGo to next message
marc.marshall is currently offline marc.marshallFriend
Messages: 30
Registered: June 2011
Member
I forgot to say that the odaDataSetHandle is then placed in a ReportDesignHandle object.

Thanks again,

Marc
Re: Parameters [message #714121 is a reply to message #714067] Tue, 09 August 2011 20:34 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Is this a dataset parameter or a report parameter?
For a report parameter set it like:
task.setParameterValue("Top Count", (new Integer(5)));

If you are using the DE API to add a dataset parameter you could do:

OdaDataSetHandle dsHandle = designFactory.newOdaDataSet( "ds2",
"org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
dsHandle.setDataSource( "Data Source" );
String qry = "Select * from orderdetails where ordernumber = ?";

dsHandle.setQueryText( qry );
designHandle.getDataSets( ).add( dsHandle );
OdaDataSetParameter parameter =
StructureFactory.createOdaDataSetParameter();
parameter.setName( "param1" );
parameter.setPosition(1);
parameter.setDataType("integer");
parameter.setAllowNull(true);
parameter.setDefaultValue("10105");
parameter.setIsOptional(false);
parameter.setIsOutput(false);
parameter.setIsInput(true);

PropertyHandle parameterHandle = dsHandle.getPropertyHandle(
DataSetHandle.PARAMETERS_PROP );
parameterHandle.addItem( parameter );

If you have the dataset handle you can set the first ds parameter like"

PropertyHandle parameterHandle = dsHandle.getPropertyHandle(
DataSetHandle.PARAMETERS_PROP );
OdaDataSetParameterHandle dsp =
(OdaDataSetParameterHandle)parameterHandle.get(0);
dsp.setDefaultValue("10101");

If the dataset parameter is linked to a report parameter, just set the
report parameter.

Jason

On 8/9/2011 2:13 PM, marc.marshall wrote:
> I have created a Web project that uses Java to build a Birt Report. I am
> using the OdaDataSourceHandle and OdaDataSetHandle to retrieve my data.
> I have placed a prepared statement in the setQueryText(sql) of my
> OdaDataSetHandle. When I run my report I get a Parameter 1 could not be
> found error. For the life of me I am unable to get the Parameter 1
> populated with a value. Does anyone know how I can populate the
> Parameter 1 in Java Code?
>
> Thanks for the help and your time in advance,
>
> Marc
Re: Parameters [message #714412 is a reply to message #714121] Wed, 10 August 2011 13:49 Go to previous message
marc.marshall is currently offline marc.marshallFriend
Messages: 30
Registered: June 2011
Member
Jason,

Thanks for the help, that code worked!

Thanks again,

Marc
Previous Topic:AxisFault for Web Service data source
Next Topic:Re: Enabling study layout in JavaScript generated axes
Goto Forum:
  


Current Time: Sun Dec 21 21:41:25 GMT 2014

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

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