Deveria ter sido uma junção externa; algo assim:
SQL> declare
2 descr varchar2(90);
3 gz_dt date;
4 date1 date :=to_date('2021-01-01','YYYY-MM-DD');
5 date2 date :=to_date('2021-01-31','YYYY-MM-DD');
6 vatt_date date;
7 vempcode number;
8 cursor c_gzdt is
9 select g.gazzeted_date, g.description, p.att_date, p.emp_code
10 from pay_in_out p left join gazzeted_days g
11 on p.att_date = g.gazzeted_date
12 and gazzeted_date between date1 and date2
13 and p.emp_code=111
14 order by p.att_date;
15 begin
16 open c_gzdt;
17 loop
18 fetch c_gzdt into gz_dt, descr, vatt_date, vempcode ;
19 exit when c_gzdt%notfound;
20
21 if vatt_date = gz_dt then
22 dbms_output.put_line(vatt_date||' THE DAY OF : '||descr);
23 else
24 dbms_output.put_line(vatt_date||' THE DAY OF : '||'PRESENT');
25 end if;
26
27 end loop;
28 close c_gzdt;
29 end;
30 /
o que resulta em
01.01.21 THE DAY OF : PRESENT
02.01.21 THE DAY OF : PRESENT
03.01.21 THE DAY OF : PRESENT
04.01.21 THE DAY OF : PRESENT
05.01.21 THE DAY OF : PRESENT
06.01.21 THE DAY OF : PRESENT
07.01.21 THE DAY OF : PRESENT
08.01.21 THE DAY OF : PRESENT
09.01.21 THE DAY OF : Its Holyday two
10.01.21 THE DAY OF : PRESENT
11.01.21 THE DAY OF : PRESENT
12.01.21 THE DAY OF : PRESENT
13.01.21 THE DAY OF : Its Holyday three
14.01.21 THE DAY OF : PRESENT
15.01.21 THE DAY OF : PRESENT
16.01.21 THE DAY OF : Its Holyday four
17.01.21 THE DAY OF : PRESENT
18.01.21 THE DAY OF : PRESENT
19.01.21 THE DAY OF : PRESENT
20.01.21 THE DAY OF : PRESENT
21.01.21 THE DAY OF : Its Holyday five
22.01.21 THE DAY OF : PRESENT
23.01.21 THE DAY OF : PRESENT
24.01.21 THE DAY OF : PRESENT
25.01.21 THE DAY OF : PRESENT
26.01.21 THE DAY OF : Its Holyday six
27.01.21 THE DAY OF : PRESENT
28.01.21 THE DAY OF : PRESENT
29.01.21 THE DAY OF : PRESENT
30.01.21 THE DAY OF : PRESENT
31.01.21 THE DAY OF : PRESENT
PL/SQL procedure successfully completed.
SQL>
A partir de Relatórios Oracle problema:ignore o PL/SQL completamente e use a consulta de cursor ligeiramente modificada como consulta do relatório. Na linha 8, você ainda usaria parâmetros, provavelmente criados nos Parâmetros do usuário do relatório no Navegador de Objetos. O relatório, presumo, obteria seus valores de outro lugar (como Oracle Forms ou Apex ou ...). O mesmo vale para o
ID
, acredito - você realmente não deseja codificar 111
, você? SQL> select p.att_date ||
2 ' THE DAY OF : ' ||
3 case when p.att_date = g.gazzeted_date then g.description
4 else 'PRESENT'
5 end result
6 from pay_in_out p left join gazzeted_days g
7 on p.att_date = g.gazzeted_date
8 and gazzeted_date between date '2021-01-01' and date '2021-01-31'
9 and p.emp_code = 111
10 order by p.att_date;
RESULT
--------------------------------------------------------------
01.01.21 THE DAY OF : PRESENT
02.01.21 THE DAY OF : PRESENT
03.01.21 THE DAY OF : PRESENT
04.01.21 THE DAY OF : PRESENT
05.01.21 THE DAY OF : PRESENT
06.01.21 THE DAY OF : PRESENT
07.01.21 THE DAY OF : PRESENT
08.01.21 THE DAY OF : PRESENT
09.01.21 THE DAY OF : Its Holyday two
10.01.21 THE DAY OF : PRESENT
<snip>
[União externa em relatórios]
Ah, sim... em Reports, você terá que usar o outer join "antigo" do Oracle
(+)
operador. O mesmo vale para case
- use decode
em vez de:select p.att_date ||
' THE DAY OF : ' ||
decode(p.att_date, g.gazzeted_date, g.description, 'PRESENT') result
from pay_in_out p, gazzeted_days g
where p.att_date = g.gazzeted_date (+)
and g.gazzeted_date (+) between date '2021-01-01' and date '2021-01-31'
and p.emp_code = 111
order by p.att_date;