Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: PK Violation on insert
George,
Here is one way:
select distinct a.DODAAC,b.NSN,c.CONTRACT count(*)
from tablea a, tableb b, tablec c
where (whatever your where clause is)
group by a.DODAAC,b.NSN,c.CONTRACT
having count(*) > 1
This will give you the PK values of those records from your select where you are producing duplicate values.
You could obviously use the 'distinct' clause in your insert statement to produce unique PK's, but this may notbe what you want.
hope this helps
Tom Mercadante
Oracle Certified Professional
-----Original Message-----
Sent: Friday, September 07, 2001 8:41 AM
To: Multiple recipients of list ORACLE-L
Good Morning,
I am selecting information from 3 tables and inserting it into a new table. My compound primary key is composed of:
DODAAC VARCHAR2(6) NSN VARCHAR2(13)
How do I find the bad data ???
TIA
Al Rusnak
804-734-8453
rusnakga_at_hqlee.deca.mil
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Rusnak, George A.
INET: rusnakga_at_hqlee.deca.mil
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists --------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists --------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Fri Sep 07 2001 - 08:20:18 CDT