View previous topic :: View next topic
|
Author |
Message |
vijayk_hr
New User
Joined: 05 Jul 2005 Posts: 3
|
|
|
|
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 |
|
|
Anbudan
New User
Joined: 07 Sep 2005 Posts: 26 Location: Germany
|
|
|
|
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 |
|
|
ovreddy
Active User
Joined: 06 Dec 2004 Posts: 211 Location: Keane Inc., Minneapolis USA.
|
|
|
|
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 |
|
|
prasanth_thavva
New User
Joined: 28 Jul 2005 Posts: 86 Location: Chennai
|
|
|
|
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 |
|
|
Nikhil Thayyil
New User
Joined: 12 Sep 2005 Posts: 5 Location: India
|
|
|
|
To eliminate the duplicates u can just use a Sort JCl. |
|
Back to top |
|
|
|