Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Query to get the parent table of a table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 213
Location: Cochin/Kerala/India

PostPosted: Sat Apr 25, 2009 9:42 am    Post subject: Query to get the parent table of a table
Reply with quote

Hi All,
Is any way to get the parent table of one particulare table.What query i need to execute to get this?


Regards,
Bipin Peter
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Apr 25, 2009 9:57 am    Post subject:
Reply with quote

Hello,

Quite often a parent/child relationship is logical rather than a physical link (as was done in non-relational systems).

I don't know of a way to guarantee discovery of all possible parent/child relationships via a query.

Depending on how your database was designed, there may be a logical data model available in some case tool that will show these relatonships.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Sat Apr 25, 2009 10:31 am    Post subject:
Reply with quote

Hi Pete,

Check out this LINK

Change the WHERE clause condition to A.TBNAME='youchildtablename'

Sushanth
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 213
Location: Cochin/Kerala/India

PostPosted: Sat Apr 25, 2009 10:51 am    Post subject:
Reply with quote

Thanks alot sushanth ,It work fine..
Bipin Peter
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Apr 25, 2009 8:26 pm    Post subject:
Reply with quote

Hello,

Quote:
It work fine..
With the exception that it will probably not detect all child tables. . . As i mentioned before, many parent/child relatonships are not so "formally" established in the meta-data.

If the query provides everything you need, great, but do be aware that there may be other p/c relationships that it cannot identify.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Sun Apr 26, 2009 1:20 am    Post subject:
Reply with quote

Hi d.sch,

Quote:
be aware that there may be other p/c relationships that it cannot identify.


Can you tell me scenario where it cannot identify.

Because, if tables are created as stand-alone tables, i.e., with no relationships with other tables.
The next Only way is to logically relate them in the program. By this method we cannot identify P/C from the catalogs.

Sushanth
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sun Apr 26, 2009 2:21 am    Post subject:
Reply with quote

Hello,

Quote:
The next Only way is to logically relate them in the program. By this method we cannot identify P/C from the catalogs.
Exactly icon_smile.gif . Many, many older systems were designed for non-relational technology and when they were converted/migrated to a relatoinal dbms (db2, for example), they were not redefined. The code already "knew" how to enforce relationship rules and continued to do so in the "new" database environment.

This is why i mentioned looking for an external "picture" of the database.

Unless one is working with a database structure that they completely designed/implemented, one should not depend on the structure containing all of the necessary information. Many (actually most, in my experienc) older databases were not completely re-vamped when they were converted to newer database software.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 18 Thu Jul 13, 2017 2:11 pm
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts unload data from table with lob columns farhad_evan DB2 1 Sat Apr 22, 2017 1:32 pm
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us