Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 如何在报表查询向导中将参数与其他值合并_Mysql_Ireport - Fatal编程技术网

Mysql 如何在报表查询向导中将参数与其他值合并

Mysql 如何在报表查询向导中将参数与其他值合并,mysql,ireport,Mysql,Ireport,我在iReport的报表查询向导中有以下查询 select docid_fname_pemid.*, MONTHNAME(b.ServicePeriodDate) as month_name,YEAR(b.ServicePeriodDate) as year_name , b.NonLTCMaximumSpecialPayment, b.NonLTCEnrolledPatientOutsideUseTotal, b.NonLTCAccessBonus from ( select docid_pe

我在iReport的报表查询向导中有以下查询

select docid_fname_pemid.*, MONTHNAME(b.ServicePeriodDate) as month_name,YEAR(b.ServicePeriodDate) as year_name , b.NonLTCMaximumSpecialPayment, b.NonLTCEnrolledPatientOutsideUseTotal, b.NonLTCAccessBonus
from (
select docid_pemid.PEMID, docid_pemid.DoctorID, b.$P{transparency_check})
from (
select DoctorID,PEMID from DoctorPEMMap where PEMID in ($P{PEMID_input}) and StartDate >= $P{StartDate}  and (EndDate <= $P{EndDate} or EndDate <= '0000-00-00') group by PEMID order by PEMID
)docid_pemid   left join  Doctors b on docid_pemid.DoctorID=b.DoctorID
) docid_fname_pemid
left  join DoctorPayments b on docid_fname_pemid.DoctorID=b.DoctorID

我认为查询没有得到“b.FirstName”。所以我使用concat函数作为concat'b.,$P{transparency_check},但它不起作用

我希望最终得到mysql查询中的b.FirstName或b.AliasFirstName


我该怎么做?

您遇到的问题与Jasper插入参数值的方式有关。如果您只使用$P{PARAMETER NAME},那么我相信它会在编译SQL之后填充参数。如果你使用$P!{PARAMETER NAME},该参数被视为文本,并在编译SQL之前填写。这就是为什么当您仅使用$P时,Jasper似乎在参数值周围插入单引号

因此,尝试改变这一点:

b.$P{transparency_check}
为此:

b.$P!{transparency_check}
并在透明度检查后删除额外的括号

检查此链接。我想这比我能解释得更好

下面是整个代码的外观。我把它格式化,使它更容易阅读

SELECT  docid_fname_pemid.*, 
        MONTHNAME(b.ServicePeriodDate) as month_name,
        YEAR(b.ServicePeriodDate) as year_name , 
        b.NonLTCMaximumSpecialPayment, 
        b.NonLTCEnrolledPatientOutsideUseTotal, 
        b.NonLTCAccessBonus

FROM 

(
    SELECT docid_pemid.PEMID, docid_pemid.DoctorID, b.$P!{transparency_check}

    FROM
    (
        SELECT  DoctorID,
                PEMID 
        FROM    DoctorPEMMap 
        WHERE   PEMID IN ($P{PEMID_input}) 
                AND StartDate >= $P{StartDate}
                AND (EndDate <= $P{EndDate} or EndDate <= '0000-00-00') 
        GROUP BY PEMID 
        ORDER BY PEMID
    ) docid_pemid   

    left join  Doctors b on docid_pemid.DoctorID=b.DoctorID

) docid_fname_pemid

left  join DoctorPayments b on docid_fname_pemid.DoctorID=b.DoctorID

,我也做了同样的操作,但在自动检索字段时,会出现相同的错误:null我忽略该错误并继续运行。当给定透明度时,它会运行,但当给定透明度时,它会运行,但当我给定透明度时,它会运行->错误填充打印。。。未知列名:FirstName正在设置文件解析程序。。。我希望transparency\u check的动态值为FristName或AliasFirstName,这取决于transparency\u inputyes/no参数部分中有问题的参数查找我检查transparency\u check的条件的语法正确吗?我觉得很正确,尽管java一直在踢我的屁股。由于错误消息引用了first_name,它看起来工作正常。测试一下。在tranparency\u检查之后,您似乎还有其他括号。
SELECT  docid_fname_pemid.*, 
        MONTHNAME(b.ServicePeriodDate) as month_name,
        YEAR(b.ServicePeriodDate) as year_name , 
        b.NonLTCMaximumSpecialPayment, 
        b.NonLTCEnrolledPatientOutsideUseTotal, 
        b.NonLTCAccessBonus

FROM 

(
    SELECT docid_pemid.PEMID, docid_pemid.DoctorID, b.$P!{transparency_check}

    FROM
    (
        SELECT  DoctorID,
                PEMID 
        FROM    DoctorPEMMap 
        WHERE   PEMID IN ($P{PEMID_input}) 
                AND StartDate >= $P{StartDate}
                AND (EndDate <= $P{EndDate} or EndDate <= '0000-00-00') 
        GROUP BY PEMID 
        ORDER BY PEMID
    ) docid_pemid   

    left join  Doctors b on docid_pemid.DoctorID=b.DoctorID

) docid_fname_pemid

left  join DoctorPayments b on docid_fname_pemid.DoctorID=b.DoctorID