This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JDBC and the fly likes db2 SQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "db2 SQL" Watch "db2 SQL" New topic
Author

db2 SQL

Shiva.Om Kumar
Ranch Hand

Joined: Jun 14, 2010
Posts: 68
Hi,

I am not sure if this is appropriate forum to post this issue, but in case you have idea, please share your view,

I am trying to write db2 SQL (Merge statement),



Above SQL works till line 4, but if I run full statement, I am getting error 23505 - A violation of the constraint imposed by a unique index or a unique constraint occurred.
But there is no such record having id as PX.
If I run following, I am able to insert


Any clue what is the missing point
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

How many rows are in the myTable table?

The WHEN NOT MATCHED clause will insert one row for every unmatched row in the source table. If there is more than one unmatched record, you'll get PK violation, because you are inserting constant values.
 
GeeCON Prague 2014
 
subject: db2 SQL