Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am
No new posts BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm
No new posts Skip file from delete pema_yozer All Other Mainframe Topics 3 Tue Aug 29, 2017 3:19 pm
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 21 Sun Aug 27, 2017 10:35 pm
No new posts editting the file by inserting zeros ... pramodrsingh DFSORT/ICETOOL 9 Mon Aug 21, 2017 5:58 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us