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

Hi,

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 - www.ibm.com/support/pages/not-enforced-primary-key-if-we-have-duplicate-records-table-it-may-lead-nondeterministic-result-query
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
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: 1042
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 Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts How to load to DB2 with column level ... DB2 6
No new posts RC query -Time column CA Products 3
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
Search our Forums:

Back to Top