Hi,
I have Agent DB2 table& a Transaction file. The transaction file has a field Agent No. I have to query the AGENT table which consists of both agent no& Employee no, to get the Employee no corresponding to the Agent no.s in the transaction file. Is this Possible?
1 more doubt.While I tried to unload the table using selective query, it was showing "SELECT" stmt is illegal.Can you tell me the reason?
Or isnt it possible to do the selective download of a DB2 table to a flat file?
Thanks,
Rinu
DB2 table -selective download to a flat file
Moderators: Kalicharan, Moderator Group
-
- Member
- Posts: 2
- Joined: Tue Apr 10, 2007 2:23 pm
Rinu,
I have Agent DB2 table& a Transaction file. The transaction file has a field Agent No. I have to query the AGENT table which consists of both agent no& Employee no, to get the Employee no corresponding to the Agent no.s in the transaction file. Is this Possible?
1 more doubt.While I tried to unload the table using selective query, it was showing "SELECT" stmt is illegal.Can you tell me the reason? Or isnt it possible to do the selective download of a DB2 table to a flat file?
Thanks,
Veera.
I have Agent DB2 table& a Transaction file. The transaction file has a field Agent No. I have to query the AGENT table which consists of both agent no& Employee no, to get the Employee no corresponding to the Agent no.s in the transaction file. Is this Possible?
Code: Select all
yes it is possible.
SELECT EMPOLYEE_NO ,AGENT_NO
FROM AGENT
WHERE AGENT_NO = :WS-Agent_No ----> This field should be from ur TRANS FILE.
We need to consider few things in the above query
1--> IT will give correct results only if you have UNIQUE AGENT_NO in the AGENT TABLE.
other wise there is a posibility that you will get duplicates for that either
you need to handle duplicates by -811 or code a CURSOR.
2---> It is always good to query the table using the full key. So instead of unloading
the only AGENT_NO try unloading the entire key fields from the file if you have
all the fields.If you query the table with out key fields, there will be tremendous
performance degradation, which is not wise to use.
3---> The above query should be executed for each record in the I/P FILE. I mean you have
to read the TRANS-FILE until EOF, and for each succesfull read you have to execute the
above query, and display or wirte into output file as per your requirement.
1 more doubt.While I tried to unload the table using selective query, it was showing "SELECT" stmt is illegal.Can you tell me the reason? Or isnt it possible to do the selective download of a DB2 table to a flat file?
Code: Select all
This should be possible, how are u trying to do this..may be something wrong with ur query systax.
As Info:
********
I think if you are trying to unload the AGENT_NO from other table into TRANS-FILE and then
using that AGENT_NO from TRANS-FILE if you are trying to select list of EMPOLYEE_NO for
the corresponding AGENT_NO, then instead of unloading into TRANS-FILE.We can directly
achieve the above by join/co-related query on 2 tables with appropriate keys thru one pass to DB2.
Well anyway unloading into TRANS-FILE is also not a bad option.
Veera.
-
- Member
- Posts: 2
- Joined: Tue Apr 10, 2007 2:23 pm
Rinu,
What you are asking of DB2 is not possible directly, but is achievable. You cannot do a query in JCL accessing a flat file. But there are ways.
Can you please post the structure of the agent table and the copybook for the transaction file? Also the copybook for the output.
I take it this is an academic exercise rather than a business problem, right? There are things that I would do as an academic exercise that I would not do as a business solution.
How much of a volume are we talking about here? Hundreds, thousands, or millions of rows/records?
Let?s see what we can come up with.
Dave
What you are asking of DB2 is not possible directly, but is achievable. You cannot do a query in JCL accessing a flat file. But there are ways.
Can you please post the structure of the agent table and the copybook for the transaction file? Also the copybook for the output.
I take it this is an academic exercise rather than a business problem, right? There are things that I would do as an academic exercise that I would not do as a business solution.
How much of a volume are we talking about here? Hundreds, thousands, or millions of rows/records?
Let?s see what we can come up with.
Dave
Rinu,
Ok let me define ur requirement first
1. You have a transaction file -> This File has field AGENT-NO
2. you have a table AGENT -> Which consists of AGENT-NO,EMPLOYEE-NO...and some more columns.
Now what is required is you need to get the EMPLOYEE-NO corresponding to the AGENT-NO from ur I/P trans file.
and you want to achieve this using only JCL.
Ok Rinu here is what i suggest..
you dint get back to us reg whether the TRANS FILE or the TABLE will have duplicates
on AGENT-NO and EMPLOYEE-NO.
well if there can be duplicates then you need few more steps .
NOTE : If you are planning to use EZT for matching then better to sort both the files on fields which we match.
whatever is suggested can be done using ONLY JCL without using ANY PROGRAM COBOL OR COBOL + DB2.
P.S : WHAT EVER YOU HAVE ASKED FOR IS NOT CLEAR AS DAVE SAID IF YOU CAN COME UP WITH ALL THE DETAILS AND STRUCURE YOUR REQUIREMENT CLEARLY THEN WE CAN GET BACK WITH BETTER SOLUTIONS.
If the suggested solution can give you and Idea how to procees we will be Glad
Thanks,
Veera.
Ok let me define ur requirement first
1. You have a transaction file -> This File has field AGENT-NO
2. you have a table AGENT -> Which consists of AGENT-NO,EMPLOYEE-NO...and some more columns.
Now what is required is you need to get the EMPLOYEE-NO corresponding to the AGENT-NO from ur I/P trans file.
and you want to achieve this using only JCL.
Ok Rinu here is what i suggest..
Code: Select all
STEP1 : Unload the AGENT table.
( All the columns OR only 2 columns AGENT-NO , EMPLOYEE-NO)
This can be done using the JCL , using a query.
on AGENT-NO and EMPLOYEE-NO.
well if there can be duplicates then you need few more steps .
Code: Select all
STEP 2: SORT THE UNLOAD FILE FROM STEP1 ON AGENT-NO AND ELIMINATE ALL THE DUPLICATES.
(SUM FIELDS = NONE , AND SORT FIELDS)
STEP 3: SORT THE TRANS FILE AND ELIMINATE DUPLICATES ON AGENT-NO
NOTE : STEP 2 AND STEP 3 are required only if you have any DUPLICATES
step 4: write one EZT matching program or SORT and then match on AGENT-NO from
both the files and when ever there is a match write into outfile from
UNLOAD FILE , which has both AGENT-NO and EMPLOYEE-NO.
whatever is suggested can be done using ONLY JCL without using ANY PROGRAM COBOL OR COBOL + DB2.
P.S : WHAT EVER YOU HAVE ASKED FOR IS NOT CLEAR AS DAVE SAID IF YOU CAN COME UP WITH ALL THE DETAILS AND STRUCURE YOUR REQUIREMENT CLEARLY THEN WE CAN GET BACK WITH BETTER SOLUTIONS.
If the suggested solution can give you and Idea how to procees we will be Glad
Thanks,
Veera.
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page