Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Modify method in Data Class

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DataInfo test = find((newData.getValues())[0]);
if ((test != null) &&
(test.getRecordNumber()!=newData.getRecordNumber()))
{
throw new DatabaseException("Attempt to create a "+
"duplicate key by modification");
}
Above is a code snippet from modify method of Data class.Do you think when a record is updated is this check required ?.Duplicate key check is only reqired when a new record is added. Is it not.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some naughty client might try to modify the key field of a record to the value of an already existing key. So it is necessary.
 
Mathew Sam
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The find method is finding a record which has the same record number.Then again checking whether both the records are having same record number.I am not understanding the logic ? Am i missing some thing?
 
HenkGijsbert
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The find method is NOT finding a method with the same record number, but with the same key value, wich is in the first field of a record:
newData.getValues()[0]. Please study the DataInfo class and the Data class to learn the difference between record number and key value.
Henk
 
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic