IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Finding Table load order


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Nov 14, 2012 7:50 pm
Reply with quote

ok, so you are saying that
- there is no table without a parent.
- you don't know which table(s) to put first;

Let's see if there are tables without children (they are last in the load order) :
Code:
select name ,
        (select count(*) from sysibm.sysrels R
         where R.creator = tb.creator    and R.tbname <> tb.name
             and r.reftbcreator = tb.creator and r.reftbname = tb.name)
from sysibm.systables tb
where creator = 'xxx'
   and type = 'T'
   and not( criteria_for_historytables)
order by 2 asc


Otherwise you might want to :
- exclude not-enforced RI (probably all defined RI is enforced as in most shops)
- exclude the RI with DELETERULE = Set NULL
Code:
select name  ,
        (select count(*) from sysibm.sysrels R
         where R.creator = tb.creator    and R.tbname = tb.name
             and r.reftbcreator = tb.creator and r.reftbname <> tb.name
             and ENFORCED = 'Y'
             and DELETERULE <> 'N')
from sysibm.systables tb
where creator = 'xxx'
   and type = 'T'
   and not( criteria_for_historytables)
order by 2 asc
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Thu Nov 15, 2012 10:17 am
Reply with quote

Hi,

I got some 333 Rows.

Lowest count = 0
Highest count = 584
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Mon Nov 19, 2012 10:01 pm
Reply with quote

I find it very discomforting that you have 333 tables and that there is a table with 584 children


ok, this is the reversed from my first query :
Select all tables without children ;
Select all parents,grandparents,... from these tables (recursive)
from all duplicate occurences of a table take the minimum lvl (= highest up in the tree)

Code:
with alltables(lvl,creator,name,list) as (
select 0 ,creator, name,cast(strip(name) as varchar(2000)) from sysibm.systables T

where type = 'T'   
and      creator = ?
and not( criteria_for_historytables)
and not exists (select * from sysibm.sysrels R
             where R.reftbname = t.name and R.CREATOR = t.CREATOR
               and R.tbname <> t.name and R.reftbCREATOR = t.CREATOR)
union all
select P.lvl - 1, r2.reftbcreator,r2.reftbname,strip(reftbname) || '>' || p.list
from alltables P, sysibm.sysrels R2
where r2.tbname = p.name and r2.creator = p.creator
  and position(strip(r2.reftbname),p.list,CODEUNITS32 ) = 0
and lvl > -20
)

select
--*
creator, name, min(lvl)
from alltables
group by creator, name
order by 3,1,2
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Tue Nov 20, 2012 11:12 am
Reply with quote

Hi GuyC,

I tried running this query. This query ran for about 1.5 hours then I cancelled.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Finding and researching jobs All Other Mainframe Topics 0
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts VB to FB - Finding LRECL SYNCSORT 4
No new posts How to load to DB2 with column level ... DB2 6
Search our Forums:

Back to Top