Symptom
When viewing a report that has a command object with a parameter that connects to a DB2 database, if you are attempting to use the setTableLocation method at runtime, the following error message appears:
"JDBC Error: DB2 SQL error: SQLCODE: -401, SQLSTATE: 42601,
SQLERRMC"
Cause
When using the setTableLocation method in the Java Reporting Component (JRC), the report contains a command object with a parameter, and you attempt to set the parameter value using the ParameterFieldController, the parameter value is not propagated to the command object. A NULL value will be sent to the database, which causes the error to appear.
Resolution
Cast your command to an IProcedure object, at which point you can extract and set the parameter value. Use the following code:
if(table instanceof com.crystaldecisions.sdk.occa.report.data.CommandTable)
{
IProcedure command = (IProcedure)table;
ParameterField commandParam = (ParameterField) command.getParameters().get(0);
Values values = new Values();
ParameterFieldDiscreteValue pfdv = new ParameterFieldDiscreteValue();
pfdv.setValue("ANTON");
values.add(pfdv);
commandParam.setCurrentValues(values);
}
Keywords
command, table, parameter, change, database, location, error, DB2, JDBC , 5088206 , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , Bug Filed