declare
obj number(12);
num number;
begin
for cur3 in (select aa_id from ls65_sid.aa_t a where a.type = 'R' and a.state = 'A' and rownum <10 and a.partition = 1010)loop
for cur4 in (select distinct bb_id from ls65_sid.bb_t a where a.aa_id = cur3.aa_id) loop
for cur1 in (select aa_id from ls65_sid.bb_t a where a.bb_id = cur4.bb_id) loop
dbms_output.put_line('aa_id = ' || cur1.aa_id);
select count(1) into num from ls65_sid.cc_t b where b.cc_id = cur1.aa_id;
if num > 0 then
select distinct b.object_id into obj from ls65_sid.cc_t b where b.cc_id = cur1.aa_id and rownum = 1;
for cur2 in (select id, state from ls65_sid.dd_t c where c.dd_id = obj) loop
dbms_output.put_line('dd_m_id = ' || cur2.id || ' ' || cur2.state);
end loop;
end if;
end loop;
end loop;
end loop;
end;
aa_id = 100252489319
aa_id = 100252489321
aa_id = 100252489323
dd_m_id = 240781668 00A
dd_m_id = 240450190 00X
dd_m_id = 240450190 00A
aa_id = 100252489326
aa_id = 100252490948
aa_id = 100252490950
aa_id = 100252490952
aa_id = 100252490953
aa_id = 100252490958
aa_id = 100252490960
dd_m_id = 9500206455 00A
dd_m_id = 9500206455 00X
dd_m_id = 240782197 00A
aa_id = 100252490956
aa_id = 100252490957
aa_id = 100252505149
aa_id = 100252505151
aa_id = 100252505153
aa_id = 100252505156
dd_m_id = 240786169 00A
dd_m_id = 9501340197 00X
dd_m_id = 9501340197 00A
aa_id = 100252505159
aa_id = 100252505161
aa_id = 100252537416
aa_id = 100252537418
dd_m_id = 272083235 00A
dd_m_id = 9500038273 00X
dd_m_id = 222418765 00A
dd_m_id = 189159349 00A
dd_m_id = 9500038273 00A
aa_id = 100252537421
aa_id = 100252537423
aa_id = 100252537424
aa_id = 100252537426
aa_id = 100252537418
dd_m_id = 272083235 00A
dd_m_id = 9500038273 00X
dd_m_id = 222418765 00A
dd_m_id = 189159349 00A
dd_m_id = 9500038273 00A
aa_id = 100252538382
aa_id = 100252542829
aa_id = 100251741971
aa_id = 100251741973
aa_id = 100251741975
dd_m_id = 240381457 00A
dd_m_id = 240573687 00A
dd_m_id = 240380673 00X
dd_m_id = 240380673 00A
aa_id = 100251741979
aa_id = 100251741981
aa_id = 100251741982
aa_id = 100251741984
aa_id = 100251742990
aa_id = 100251742992
aa_id = 100251742994
aa_id = 100251742997
dd_m_id = 240573992 00A
dd_m_id = 9001241194 00X
dd_m_id = 9001241194 00A
aa_id = 100251743000
aa_id = 100251743002
aa_id = 100251743182
aa_id = 100251743184
dd_m_id = 9000134878 00X
dd_m_id = 240574057 00A
dd_m_id = 9000134878 00A
aa_id = 100251743187
aa_id = 100251743189
aa_id = 100251743190
aa_id = 100251743192
aa_id = 100251540932
aa_id = 100251540935
aa_id = 100251540937
aa_id = 100251540944
dd_m_id = 240512436 00A
dd_m_id = 240500556 00X
dd_m_id = 240512426 00A
dd_m_id = 244689277 00A
dd_m_id = 240500556 00A
aa_id = 100251540948
aa_id = 100251540950
aa_id = 100251540952
aa_id = 100251540957
aa_id = 100251540941
aa_id = 100251540943
aa_id = 100251540955
aa_id = 100251540956
aa_id = 100251540944
dd_m_id = 240512436 00A
dd_m_id = 240500556 00X
dd_m_id = 240512426 00A
dd_m_id = 244689277 00A
dd_m_id = 240500556 00A
aa_id = 100269074327
aa_id = 100269083424
aa_id = 100269083425
aa_id = 100251748034
aa_id = 100251748036
dd_m_id = 9000088832 00X
dd_m_id = 239758272 00A
dd_m_id = 9000088832 00A
aa_id = 100251748039
aa_id = 100251748041
aa_id = 100251748042
aa_id = 100251748044