Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Inserting records to DB2 from file, with primary key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
vijayk_hr

New User


Joined: 05 Jul 2005
Posts: 3

PostPosted: Thu Sep 08, 2005 8:41 pm    Post subject: Inserting records to DB2 from file, with primary key
Reply with quote

Dear All,
I need some input for the following from your side..please.

I have flat file and i need to read one by one records from this file and have to insert it into DB2 table. There is a primary key for this table.
Here what are the scenario i have to handle to avoid duplicate insertion error and others ...

here my doubt is ..how to handle duplicate insertion error and how to have unique key ..

Need help .........

Thanks,
Vijay[color=blue]
[/color]
Back to top
View user's profile Send private message

Anbudan

New User


Joined: 07 Sep 2005
Posts: 26
Location: Germany

PostPosted: Fri Sep 09, 2005 6:27 pm    Post subject:
Reply with quote

Hi Vijay

If duplicate ' means' - complete record(NOT single field), Then
I) create temp field(say Pic 80) in WS

1)Open the file
2)Read file
3)compare with remp field (check 'y' or 'n')
4)Move the record into temp field
5)insert into table


Any doubt, dont hesitate to ask

Regards
Anbudan
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Mon Sep 12, 2005 12:21 pm    Post subject:
Reply with quote

Hi Vijay,

You go through the following steps...

1. Read File
2. Move File Variables into Host Variables
3. Execute Insert statement
4. IF SQLCODE=-803 THEN
DO ROLLBACK;
ELSE
IF SQLCODE = 0 THEN
DO COMMIT;

But It will take a long time. If it is a one time program then its ok. Other wise follow the steps suggested by Anubudan.

Thanks,
Reddy.
Back to top
View user's profile Send private message
prasanth_thavva

New User


Joined: 28 Jul 2005
Posts: 86
Location: Chennai

PostPosted: Mon Sep 12, 2005 3:46 pm    Post subject: duplicate elimination of a file while inserting into table
Reply with quote

hi,
two conditions u wll get one is
Quote:
one that depends on table definition


Quote:
-803 duplicate record found


if junk values moves to host variable -305 u have to handle this situation
usually 0-- do the normal process

IF wrong plz correct me
bye
Back to top
View user's profile Send private message
Nikhil Thayyil

New User


Joined: 12 Sep 2005
Posts: 5
Location: India

PostPosted: Tue Sep 13, 2005 10:07 am    Post subject: Duplicate Handling
Reply with quote

To eliminate the duplicates u can just use a Sort JCl.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us