Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Error when using a collection as a parameter at the URL #50

#1

Hello!, How can I pass a Collection to the p_additional_params?

I've tried almost every combination.

I found the following error when running a report directly from the URL:

An error occured.
Please contact your local administrator.
net.sf.jasperreports.engine.JRRuntimeException: Invalid type java.lang.String for parameter i_creditos used in an IN clause; the value must be an array or a collection.
at net.sf.jasperreports.engine.query.JRSqlAbstractInClause.convert(JRSqlAbstractInClause.java:260)
at net.sf.jasperreports.engine.query.JRSqlAbstractInClause.apply(JRSqlAbstractInClause.java:141)
at net.sf.jasperreports.engine.query.JRAbstractQueryExecuter.applyClause(JRAbstractQueryExecuter.java:569)
at net.sf.jasperreports.engine.query.JRAbstractQueryExecuter.appendClauseChunk(JRAbstractQueryExecuter.java:563)
at net.sf.jasperreports.engine.query.JRAbstractQueryExecuter.appendQueryChunk(JRAbstractQueryExecuter.java:404)

I need to use a collection in order to make this line works:

WHERE $X{IN, numero_radicacion, i_creditos}

In my current APP, we receive the parameter as a CSV and handle the collection with the following code.

for (Map.Entry<String, String[]> entry : requestParams.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue()[0];
        if (!key.equalsIgnoreCase("cs")) {
            if (key.toUpperCase().startsWith("L_")) {
                String[] split = value.split(",");
                Collection<String> col = new ArrayList<>(Arrays.asList(split));
                parameters.put(key, col);
                allParams = allParams.concat("[" + key + "=" + col + "]");
            } else {
                parameters.put(key, value);
                allParams = allParams.concat("[" + key + "=" + value + "]");
            }
        }
    }

I hope you can help me so I can finish my migration to JRI.

Thanks!

  • replies 1
  • views 473
  • likes 0
#2

Hi,

I am not sure, I fully understand the use case.

Can you post a simplified version of the pl/sql call and also the SQL query in the .jrxml report file?
That Java code doesn't really make sense to me.

You should have a SQL query in the report, right?

Thank you
Dietmar.