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

How to find the tables names.


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

New User


Joined: 23 Dec 2008
Posts: 7
Location: Bangalore

PostPosted: Tue Jan 20, 2009 5:39 pm
Reply with quote

Hi All,

I want to retrieve the table names which contains the value as ‘Germany’ in different fileds of tables.

Suppose.
Table1
Column1 Column2 Column3 Column4 Column5
India
Germany
USA
Germany

Table3
Column1 Column2 Column3 Column4 Column5
Germany
Lonon
Germany
Japan

Table3
Column1 Column2 Column3 Column4 Column5
Australia
Lonon
Germany
Japan

-
-
-
-
-

upto 50 tables are there. I want to retrieve the table names out of 50 which contains 'Germany' as a column value.

Write a single SQL query. There is no key columns in all the tables.

Hope I am clear.
Thanks in advance
Back to top
View user's profile Send private message
abhishek dadhichi

New User


Joined: 19 Apr 2007
Posts: 37
Location: Bangalore

PostPosted: Tue Jan 20, 2009 5:53 pm
Reply with quote

Hi ramanatcs,

Plz try the following query:

sel * from dbc.tables where column_name=germany





Thanks,
Abhishek
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Jan 20, 2009 6:26 pm
Reply with quote

Dick, can I vote for the answer? Since it doesn't meet the stated requirements, it can't really be considered an answer to the question. Although the question is lame, at least the person is wanting help.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jan 20, 2009 8:09 pm
Reply with quote

you are right, Robert.

If I had edit authority on this board I would amend/delete my post. Done

as far as an answer to the OP's question, I don't know how to extract the table name and validate a table column's value for 50 tables in one SQL.
Code:

Select 'table name one'
   from table-name-one
 where column = 'Germany'
UNION
Select 'table name two'
   from table-name-two
 where column = 'Germany'
...
UNION
Select 'table name 50'
   from table-name-50
 where column = 'Germany'



maybe someone else can provide an answer.

I apologize to ramanatcs and Abhishek. My previous post was needlessly rude and did not contribute to the thread.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue Jan 20, 2009 9:45 pm
Reply with quote

Hello,

Quote:
Write a single SQL query.
Why? Probably because "I want. . .". Maybe it is some homework assignment.

Given the complete lack of specification of what is really needed (it appears to be a list of every table that has the word "Germany" anywhere in the table?), one way might be to unload the tables and scan the unloaded output for the word "Germany".
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 To find whether record count are true... DFSORT/ICETOOL 6
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts Need to fetch data from so many DB2 t... DB2 9
No new posts Capturing COBOL job and program names... All Other Mainframe Topics 2
No new posts Find the occurrence of Key Field (Par... DFSORT/ICETOOL 6
Search our Forums:

Back to Top