How to create report [message #583372] |
Tue, 30 April 2013 05:49 |
snsiddiqui
Messages: 172 Registered: December 2008
|
Senior Member |
|
|
Dear All
I want to create report using this query, is there any option? please reply.
declare
cursor c2 is
select epi_id, epi_code, epi_name
from emp_personal_info
where epi_status = '32'
order by epi_code;
cursor c1 is
select distinct eam_datein
from emp_atnd_mast
where to_char(eam_datein,'fmday') = 'sunday'
and eam_datein between '01-APR-2013' and '30-APR-2013'
order by eam_datein;
rec c1%rowtype;
rec1 c2%rowtype;
satapsnt comm_setups_setup.css_id%type;
monapsnt comm_setups_setup.css_id%type;
begin
for rec1 in c2 loop
for rec in c1 loop
begin
select eam_status
into satapsnt
from emp_atnd_mast
where eam_epi_id = rec1.epi_id
and eam_datein = rec.eam_datein - 1
and eam_status = '24';
exception
when no_data_found then
satapsnt := Null;
end;
begin
select eam_status
into monapsnt
from emp_atnd_mast
where eam_epi_id = rec1.epi_id
and eam_datein = rec.eam_datein + 1
and eam_status = '24';
exception
when no_data_found then
monapsnt := Null;
end;
if satapsnt is not null and monapsnt is not null then
dbms_output.put_line(rec1.epi_code||' - '||rec1.epi_name||' - '||rec.eam_datein);
end if;
end loop;
end loop;
end;
[Updated on: Tue, 30 April 2013 05:50] Report message to a moderator
|
|
|
|
|
|
Re: How to create report [message #583400 is a reply to message #583391] |
Tue, 30 April 2013 08:02 |
cookiemonster
Messages: 13961 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Just join the queries. Here's a bit to get you started, replacing the 2 cursors:
select epi.epi_id, epi.epi_code, epi.epi_name
from emp_personal_info epi
CROSS JOIN (SELECT distinct eam_datein
from emp_atnd_mast
where to_char(eam_datein,'fmday') = 'sunday'
and eam_datein between to_date('01-APR-2013', 'DD-MON-YYYY') and to_date('30-APR-2013', 'DD-MON-YYYY')
)
where epi_status = '32';
Now add joins for the 2 select intos.
|
|
|