Как запустить условно sql в ireport? - PullRequest
1 голос
/ 19 марта 2019

Я хочу вызвать два отдельных sql в ireport, но он показывает ошибку, как в редакторе выражений 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"

1 Ответ

1 голос
/ 04 апреля 2019

Пожалуйста, попробуйте изменить:

$P{personelId}.equals(null)? "":"" 
to 
$P{personelId} == null ? "":"" OR $P{personelId}.equals("null") ? "":"" 

OR

попробуйте адаптироваться в вашем коде (пример в 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')

Это работа для меня.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...