IBM Mainframe Forum Index
Log In
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register

Can we Insert duplicates in Primary Unique column ?

IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Poha Eater

New User

Joined: 31 Aug 2016
Posts: 74
Location: India

PostPosted: Thu Nov 05, 2020 9:09 pm
Reply with quote


There are three columns in a table, ex : C1 | C2 | C3
All three columns are defined as PU (Primary unique) and i think these three columns all together creates a composite key.

The issue is one of our Batch cycle Support member is saying that he got a SQL abend for SQLSTATE - 21000 with duplicate value in a column C3 while fetching value from column C3 through a SELECT query in COBOL-DB2 program. So he edited that value in C3 in the table so that it will not be a duplicate and he resumed the batch cycle.

I was trying to find out if this is possible or not, i have encountered the below link where it is mentioned about using NOT ENFORCED for PU column if i have got that correctly. But i am still not able to grasp everything from this link so the concept is still not clear to me.

Can anyone please explain if we can insert duplicates in Primary Unique column using NOT ENFORCED ?

Link -
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator

Joined: 21 Sep 2010
Posts: 2942
Location: NYC,USA

PostPosted: Thu Dec 17, 2020 7:51 pm
Reply with quote

If it has a unique index then you can't.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member

Joined: 31 Oct 2006
Posts: 1035
Location: Richmond, Virginia

PostPosted: Fri Dec 18, 2020 3:32 am
Reply with quote

Poha - if you want to become an expert, then you should first of all rely on your own testing, rather than take someone else's (even an expert's) word for it.

I suggest you create a suite of test programs for every feature you question. Not only will you remember the answer better a year form now when a situation again arises, but you'll become the leader in your own group.

You can also pass them on to junior members of your group when they join.

Your question above seems ideally suited for a variety of tests with different combinations of options, etc.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2


Similar Topics
Topic Forum Replies
No new posts Cobol prog to put an indicator on the... JCL & VSAM 1
No new posts Merge files with a key and insert a b... DFSORT/ICETOOL 6
No new posts Repeat a DD line- comment and insert ... CA Products 3
No new posts Split a record with data in a differe... DFSORT/ICETOOL 8
No new posts How to remove block of duplicates DFSORT/ICETOOL 8
Search our Forums:

Back to Top