Collection of dates as a parameter?

0

Is it possible to use dates (java.sql.Date, java.sql.Time, java.sql.Timestamp or java.util.Date) as a collection when creating a parameter?

I want an input control where you select multiple dates that are returned by a SQL query. Then the report query would have a WHERE clause using $X{IN, date_column, date_parameter}. This works for other data types, but the $X{IN, , } function appears to not work with dates. I get

ERROR: operator does not exist: date = character varying
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.

My database is PostgreSQL, if that makes a difference.

An example report would be:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final 
     using JasperReports Library version 6.6.0 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
              name="Blank_A4" pageWidth="595" pageHeight="842"
              columnWidth="555" leftMargin="20" rightMargin="20"
              topMargin="20" bottomMargin="20"
              uuid="9b74a295-79a1-4fa7-ae90-4fc91e070294">
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter"
              value="izziWorks24 Data Adapter "/>
    <parameter name="Parameter1" class="java.util.Collection" nestedType="java.util.Date"/>
    <queryString language="SQL">
        <![CDATA[select foo.date_col as col1 from (SELECT current_date as date_col) as foo where $X{IN, foo.date_col, Parameter1}]]>
    </queryString>
    <field name="col1" class="java.sql.Date">
        <property name="com.jaspersoft.studio.field.label" value="col1"/>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="30" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="100" height="30"
                               uuid="03eee6f8-f793-4464-bd28-38e006591e62">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID"
                              value="fdb8a0f0-4e66-4057-a1c6-260297cfd3b3"/>
                </reportElement>
                <text><![CDATA[col1]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="30" splitType="Stretch">
            <textField>
                <reportElement x="0" y="0" width="100" height="30"
                               uuid="2fcedfc1-0f91-420d-a58f-ddef251ac0f0">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID
                              value="fdb8a0f0-4e66-4057-a1c6-260297cfd3b3"/>
                </reportElement>
                <textFieldExpression><![CDATA[$F{col1}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

craig_25's picture
Joined: Nov 22 2018 - 10:51am
Last seen: 1 month 2 days ago

0 Answers:

No answers yet
Feedback
randomness