Need help on my script. I'm trying to capture all data but doc_table key column(stored date) is messed up and I need to somehow to capture the data that does not meet the critieria. For example, if stored date (key) is documented before entertime than I want key field to be entertime.
Thanks for your help.
------------------------------------------------
declare
cursor c_unit is
select distinct r.patid, r.minorit, r.key, r.name, u.unit, u.entertime , u.exittime
from (select distinct a.patid, a.minorit, a.key, p.name
from doc_table a,
name_table p
where a.patid=p.patid ) r ,
unit_table u
where r.patid=u.patid
and r.key between u.entertime and nvl(u.exittime, sysdate) ;
begin
For v_unit In c_unit loop
if v_unit.key < v_unit.entertime then
V_unit.key := v_unit.entertime ;
dbms_output.put_line( v_unit.ptname ||', '||
v_unit.unit ||', '||
v_unit.patid ||', '||
v_unit.key ||', '||
v_unit.entertime||', '||
v_unit.exittime ) ;
else
dbms_output.put_line( v_unit.ptname ||', '||
v_unit.unit ||', '||
v_unit.patid ||', '||
v_unit.key ||', '||
v_unit.entertime||', '||
v_unit.exittime ) ;
end if ;
end loop;
end;
/
Thanks for your help.
------------------------------------------------
declare
cursor c_unit is
select distinct r.patid, r.minorit, r.key, r.name, u.unit, u.entertime , u.exittime
from (select distinct a.patid, a.minorit, a.key, p.name
from doc_table a,
name_table p
where a.patid=p.patid ) r ,
unit_table u
where r.patid=u.patid
and r.key between u.entertime and nvl(u.exittime, sysdate) ;
begin
For v_unit In c_unit loop
if v_unit.key < v_unit.entertime then
V_unit.key := v_unit.entertime ;
dbms_output.put_line( v_unit.ptname ||', '||
v_unit.unit ||', '||
v_unit.patid ||', '||
v_unit.key ||', '||
v_unit.entertime||', '||
v_unit.exittime ) ;
else
dbms_output.put_line( v_unit.ptname ||', '||
v_unit.unit ||', '||
v_unit.patid ||', '||
v_unit.key ||', '||
v_unit.entertime||', '||
v_unit.exittime ) ;
end if ;
end loop;
end;
/