SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Duplicate primarykeys
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

db17
Starting Member

2 Posts

Posted - 10/05/2012 :  19:06:31  Show Profile  Reply with Quote

PM_KEY PCN PM_VERNO
20 137 0
21 137 1
22 137 2
23 137 3
22 137 2


I have a dilemma……the constraint was disable somehow in my table of about 900,000 records which allowed the insertion on duplicate primary keys as well as duplicate records. I’ve managed to get rid of the duplicate records, but I haven’t quite figured out how to update the primary key and version number. I’ve tried the following but
UPDATE TABLE
SET PM_PM_KEY=(MAX(PM_KEY)+1), PM_VERNO=(MAX(PM_VERNO)+1)
WHERE TBLDATE= MAX(TBLDATE)
ORDER BY TBLDATE ASC
GROUP BY PCN;

The query is failing with
Error at Command Line:2 Column:19
Error report:
SQL Error: ORA-00934: group function is not allowed here
00934. 00000 - "group function is not allowed here"
*Cause:
*Action:

I will appreciate any and all help

robvolk
Most Valuable Yak

USA
15663 Posts

Posted - 10/05/2012 :  21:19:21  Show Profile  Visit robvolk's Homepage  Reply with Quote
SQLTeam is a Microsoft SQL Server website. You can get help with Oracle questions at http://dbforums.com/
Go to Top of Page

pakhireddy
Starting Member

India
2 Posts

Posted - 10/06/2012 :  11:33:27  Show Profile  Reply with Quote
hi
for duplication of primary key information u can find in below link
http://www.gcreddy.net/2010/03/sql-for-testers.html
Go to Top of Page

db17
Starting Member

2 Posts

Posted - 10/08/2012 :  09:32:17  Show Profile  Reply with Quote
Thanks for pointing me in the right direction.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000