Menu

#74 Update problem

closed
None
5
2012-10-04
2011-02-25
Serg
No

Hello,

I get “violates uniqueness constraint for index Name: (Order Details) PrimaryKey” error when I try to update a row in a table. Although I wanted to update a column that is not a part of primary key …

I tested standard \"Northwind\" database.

Here is a test:

Database db = Database.open(new File(\"c:/java/test/files/northwind/nw2000.mdb\"));
Table t = db.getTable(\"Order details\");
Map rowMap = t.getNextRow();

Object[] oldRow = new Object[t.getColumns().size()];

for (int i = 0; i < t.getColumns().size(); i++) {
  Column mdbColumn = t.getColumns().get(i);
  oldRow[i] = rowMap.get(mdbColumn.getName());
}

// old row [10248, 11, 14.0000, 12, 0.0]

// update \"Quantity\" column that is not a part of a primary key column
// new row [10248, 11, 14.0000, 15, 0.0]
Object[] newRow = oldRow;
newRow[3] = new Short((short) 15);

t.updateCurrentRow(newRow); // -> exception

db.close();

Discussion

  • Serg

    Serg - 2011-02-25
     
  • Serg

    Serg - 2011-02-25

    MDB is also attached (I deleted all reports to decrease the file size)

     
  • James Ahlborn

    James Ahlborn - 2011-02-25

    thanks. i can recreate the exception. i'll look into when i get a chance.

     
  • James Ahlborn

    James Ahlborn - 2011-02-26

    okay, i have a handle on the problem at this point. jackcess is not correctly matching up the index information (the wrong index is marked as "primary key").

     
  • James Ahlborn

    James Ahlborn - 2011-02-27

    fixed in the trunk, will be in the 1.2.3 release.

     

Log in to post a comment.