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 of max. number of table references in a query

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
Uttank
Beginner


Joined: 12 Feb 2004
Posts: 12
Topics: 9

PostPosted: Sun Sep 19, 2004 10:42 pm    Post subject: problem of max. number of table references in a query Reply with quote

Question
We are using a query in a JCL to get a report. But we are getting an error message that the number of table references in the query is more than 15.
In order to resolve this, we thought of passing value (instead of using a join of tables) from one step of JCL (which would contain the output of the first query) to the SQLINP step of the JCL which contains the final query. In other words, break the query into two and pass value from one query to another. For example,
Query 1 : SELECT aaa FROM bbb WHERE ccc = '123' --> OUTPUT = &var
Query 2 : SELECT mmm FROM nnn WHERE ooo = &var

We do not know how to proceed exactly.
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon Sep 20, 2004 8:45 am    Post subject: Reply with quote

Uttank,

You probably need to format the output from the query 1. It can be done but there are many things to be taken into consideration. Any sql query cannot exceed 32767. So if your output from query 1 results in more rows then you need to split the sql once again.

Why don't you code a single program with the following logic?

1. Declare a cursor on the main table(BBB)
2. Fetch the record
3. Look up the record in dependent tables(NNN)
4. Repeat the steps(1-3) until you reach the EOF cursor

Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Uttank
Beginner


Joined: 12 Feb 2004
Posts: 12
Topics: 9

PostPosted: Mon Sep 20, 2004 10:19 pm    Post subject: Reply with quote

Thanks for the prompt reply.

For us, the query 1 returns a single value (1 row, 1 column) that we need to use in the query 2. Can you give us the exact syntax in a JCL by which we can pass the output of query 1 to query 2? That's the exact solution we are looking for.

Thanks,
Uttank
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Tue Sep 21, 2004 7:43 am    Post subject: Reply with quote

Uttank,

You can generate sql statements like as shown here.

Code:

SELECT CHAR('SELECT aaa FROM DEPENDENT_TABLE')           
      ,CHAR('WHERE COL1 = ')                         
      ,CHAR('''')                                     
      ,column to be selected
      ,CHAR('''')                                     
      ,CHAR(';')                                     
  FROM MAIN_TABLE
  ;   


This will generate a statement like this

Code:

SELECT aaa FROM DEPENDENT_TABLE WHERE COL1 = 'some value' ;


Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) 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