Fetch inserted DB2 table row using Left Join withhold cursor

Ask question on - DataBase Concepts, IBM Mainframe DB2, DB2/UDB, DB2 Tools, SQL , DB2 programming with languages like COBOL, PL1.

Moderators: Kalicharan, Moderator Group

Post Reply
bashir
Member
Posts: 3
Joined: Mon Mar 25, 2013 10:22 pm

Fetch inserted DB2 table row using Left Join withhold cursor

Post by bashir » Fri May 10, 2013 10:30 pm

I have an issue as follows.
1. I do Left Join Table A and B.
2. Insert rows into Table-B thru DB2-cobol prog.
3. Table-A has a Foreign key (e.g A-KEY) which is Primary key of Table-B.
4. The primary key of Table-B is compund key (e.g X(column)+B-KEY). B-KEY is foreign key in table_A ( A-KEY).
5. Therefore Table-B would have multiple rows like X+B-KEY, X1+BKEY...
6. Row Insert is ok as I check EXIST condition for row into Table-B before insert when key of Table-A and Table_B is matched.

PROBLEM: When a row exist on Tbale-B, row insert is successfull but fetching the same inserted row instead of going to fwtch next row (of the resultant table of left join). I handle the dup insert but the no of input rows selected shows more than the no of row selected by left join). Where as I Decalre cursor in procedure Div. using "with hold" statement.
Is there any solution to fix this issue? I need your assistance to fix it, thanks. Please reply this topic. (E-addr removed)

Best regards

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Sat May 11, 2013 7:26 pm

Do not post your email address - unless you really want spammera sending you all sorts of dubious mail. Also, answers should be given on the forum as that is where you posted the query.
Regards
Nic

bashir
Member
Posts: 3
Joined: Mon Mar 25, 2013 10:22 pm

DB2 Table Left join problem

Post by bashir » Sun May 12, 2013 11:54 pm

Thanks for notification about email in Question.

Please reply to my DB2 problem, thanks. Bashir

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Wed May 15, 2013 2:29 am

I suspect your code is Not creating a temporary table and the inserted rows are "later" in the set of selected rows. This causes them to be processed.

If a temporary table was created, the newly inserted rows would not be in the found set.
Have a good one

Post Reply

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



Other References
Mainframe Tools and others