MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem about executing same query on number of tables

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
mangsk
Beginner


Joined: 05 Jun 2004
Posts: 46
Topics: 18

PostPosted: Fri Mar 18, 2005 5:39 am    Post subject: Problem about executing same query on number of tables Reply with quote

Hi All,
My requirement is - I've to execute the same query
e.g. say
EXEC SQL
SELECT COUNT (*)
INTO :WS-COUNT
FROM table-name
on 50 different tables in a COBOL program and process the count after each time.
Is there any way to do it other than writing the same query 50 times? The table names I've already stored in an array. I tried out defing a variable as WS-TBL-NAME in which I'll move the table name from array and use this variable in FROM. But it doesn't work.
Please advice.

Thanks.
_________________
Regards,
Mangsk
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
SureshKumar
Intermediate


Joined: 23 Jan 2003
Posts: 211
Topics: 21

PostPosted: Fri Mar 18, 2005 8:44 am    Post subject: Reply with quote

Mangsk,
Its not just about doing 50 times but also plan for would be more efficient. You can try dynamic SQL, its going to add to the cost. Maybe, try opening a cursor with a union ALL, like
SELECT 'FROM TABLE 1',COUNT(*)
FROM TABLE 1
UNION ALL
SELECT 'FROM TABLE 2',COUNT(*)
FROM TABLE 2
UNION ALL
SO ON

try it, check for performance.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group