|
|
Re: Parameters [message #714121 is a reply to message #714067] |
Tue, 09 August 2011 20:34 |
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.02929 seconds