I have a report that contains 2 SQL commands.
Both of these commands use one parameter X of type Number in their 'WHERE' clause.
When i'm viewing the report in CR 2008, i'm asked for a value of this parameter and all data is filled in the report - OK
The problem occurs when the same report is printed through Crystal Java Runtime:
Report is printed without data! - it's empty.
What we noticed in the debug information thrown by the Crystal libraries is that parameter value is set only in one of these commands:
Original statement 1:
select a.something from ANM_T a where a.anmid = {?PARAMETER01Id}
Original statement 2:
SELECT * from ANM_T a WHERE a.anmid={?PARAMETER01Id}
OUTCOME of Statement 1:
select a.something
from ANM_T a
where a.anmid = 0
OUTCOME of Statement 2:
SELECT * from ANM_T a
WHERE a.anmid=9825
In above example we may see that crystal set the value only in the second statement - first one got 0 - i suspect its some default value.
Parameter in the Java code is set in the right way. In case of using only one statement it works. If we use two separate parameters (whose values are equal ) it also works.
// we have also the loop over the parameters ... ParameterFieldController paramFieldController = report.getDataDefController().getParameterFieldController(); paramFieldController.setCurrentValue( "", paramName, paramValue ); ...
What is strange for me is that Crystal Reports enables to use the same parameter in two commands but if you edit one of them you may change the type of this parameter for a command ( for example from Number to String) but the parameter type in the second command remains unchanged ( it's strange because in my opinion it is the same parameter). In the Field Explorer under the Parameter Fields i still see one parameter of type used in the second command.