how do you modify the value of the primary key of a record?

kenyo
kenyo Member Posts: 40
So whenever i try a MODIFY i get the error " "Table.Field" 'NEW_VALUE' does not exist " seems like it tries to find the record with the new primary key value which obviously doesn't exist yet in the table... so how am i supposed to change the value of the primary key field then? Do i have to delete the old row and insert a new one? seems weird to me.

Best Answer

Answers

  • kenyo
    kenyo Member Posts: 40
    oh thank you , wasn't aware of that
  • serdarulutas
    serdarulutas Member Posts: 50
    Sometimes RENAME took long time. I have had success with:

    NewRec = OldRec
    OldRec.Delete;
    NewRec.PrimaryKey = NewValue
    NewRec.Insert;
  • ShaiHulud
    ShaiHulud Member Posts: 228
    Sometimes RENAME took long time. I have had success with:

    NewRec = OldRec
    OldRec.Delete;
    NewRec.PrimaryKey = NewValue
    NewRec.Insert;

    There's a reason it "took long time" - it also needs to look up all related records (where Table Relation is pointing to the field you're changing) and modify values there as well. Imagine renaming Country or Currency without changing all the instances of them on related tables - it would be chaos!