我想在ireport中调用独立的两个sql,但它显示的错误类似于在ireport表达式编辑器中使用双引号或不使用双引号的报表查询,但它不起作用?为什么?我使用postgresql作为数据库。怎么解决?
我的代码如下:
$P{personelId}.equals(null)?"select veriler.*, toplamgun.miktar
from
(select *
from crosstab('select id, ad, soyad, calisma_tipi, sgk_no, ihale_tarihi, giris_tarihi, cikis_tarihi, pirim_gun_sayisi, gun, izin_durum from f_grp_prod('''|| $P{ay} ||''', ''' || $P{yil} || ''' ) order by 1,2',
$$values ('1'::text), ('2'), ('3'), ('4'), ('5'),('6'), ('7'), ('8'), ('9'), ('10'),('11'),
('12'), ('13'), ('14'), ('15'),('16'), ('17'), ('18'), ('19'), ('20'),('21'), ('22'), ('23'), ('24'),
('25'),('26'), ('27'), ('28'), ('29'), ('30'),('31')$$)
as t("id" bigint, "ad" text, "soyad" text, "calisma_tipi" text, "sgk_no" text, "ihale_tarihi" text, "giris_tarihi" text, "cikis_tarihi" text, "pirim_gun_sayisi" text, "1" text, "2" text, "3" text, "4" text, "5" text, "6" text, "7" text, "8" text, "9" text, "10" text,
"11" text, "12" text, "13" text, "14" text, "15" text, "16" text, "17" text, "18" text,
"19" text, "20" text, "21" text, "22" text, "23" text, "24" text, "25" text, "26" text, "27" text,
"28" text, "29" text, "30" text, "31" text))veriler
inner join
(select count(izin_durum) as miktar, id from f_grp_prod('01','2019') where izin_durum = 'X' group by id) toplamgun
on veriler.id = toplamgun.id":
"select veriler.*, toplamgun.miktar
from
(select *
from crosstab('select id, ad, soyad, calisma_tipi, sgk_no, ihale_tarihi, giris_tarihi, cikis_tarihi, pirim_gun_sayisi, gun, izin_durum from f_grp_prod('''|| $P{ay} ||''', ''' || $P{yil} || ''' $P{yil} || ''' ) order by 1,2',
$$values ('1'::text), ('2'), ('3'), ('4'), ('5'),('6'), ('7'), ('8'), ('9'), ('10'),('11'),
('12'), ('13'), ('14'), ('15'),('16'), ('17'), ('18'), ('19'), ('20'),('21'), ('22'), ('23'), ('24'),
('25'),('26'), ('27'), ('28'), ('29'), ('30'),('31')$$)
as t("id" bigint, "ad" text, "soyad" text, "calisma_tipi" text, "sgk_no" text, "ihale_tarihi" text, "giris_tarihi" text, "cikis_tarihi" text, "pirim_gun_sayisi" text, "1" text, "2" text, "3" text, "4" text, "5" text, "6" text, "7" text, "8" text, "9" text, "10" text,
"11" text, "12" text, "13" text, "14" text, "15" text, "16" text, "17" text, "18" text,
"19" text, "20" text, "21" text, "22" text, "23" text, "24" text, "25" text, "26" text, "27" text,
"28" text, "29" text, "30" text, "31" text))veriler
inner join
(select count(izin_durum) as miktar, id from f_grp_prod('01','2019') where izin_durum = 'X' group by id) toplamgun
on veriler.id = toplamgun.id"
最佳答案
请尝试更改:
$P{personelId}.equals(null)? "":""
to
$P{personelId} == null ? "":"" OR $P{personelId}.equals("null") ? "":""
或者
尝试在代码中进行调整(MySql中的示例):
select if($P{personelId} is null,'flagA','flagB') flag_personelId
from if($P{personelId} is null,'testA','testB') table_test
where findA = if($P{personelId} is null,'0','1')
这是我的工作。