Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2012
    Posts
    1

    Unanswered: Duplicate Primarykey

    PM_KEY.. PCN....... jobno..... PM_VERNO
    20......... 137....... XX23..... 0
    21......... 137....... XX24..... 1
    22......... 137....... XX17..... 2
    23......... 137....... XX81..... 3
    22......... 137....... XX90..... 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

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    UPDATE TABLE
    SET PM_PM_KEY=(MAX(PM_KEY)+1), PM_VERNO=(MAX(PM_VERNO)+1)
    WHERE TBLDATE= MAX(TBLDATE);

    above is valid SQL syntax
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •