BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Interface between Objects and Database

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Thomas Blankschein
Guest





PostPosted: Fri Jun 27, 2003 9:27 pm    Post subject: Interface between Objects and Database Reply with quote



Hi,

I'm designing an application which will use several different self created
objects. These objects have properties which have to be stored in a database
(Oracle 8.1.7). Now I'm unsure how to manage the read/write things. On
creation of an object identified by an ID, I can load the persistent data
from the associated table and store it in the object's properties. Then I
could manipulate the properties in my application according to the business
logic. Then I call a Save() method in the object which writes the values
back in the database. Sounds very simple. But what about concurrent reading
and writing? Lets say, I create an object with the ID 1, reading the
database and setting the property A to 100. The business logic says that A
shall not get negative. Now my application looks at property A and decides
"100 is enough for my operation, I can decrease it by 90". The application
sets A in object 1 to 10 and calls the Save-method of the object. 10 is
stored in the database. In parallel, another user created also an object in
his application, based on the ID 1. He also sees 100 as the value for A and
decides to decrease it by 50. If he calls the Save method after the first
user, 50 will be the stored value. I want to make sure that the second user
reads the value 10 and decides "10 is not enough, I can't decrease it by
50." All the database cuncurrency control which Oracle offers does not work
here, because I have an additional layer (the object in the application). My
actual (theroretical) solution for this is the implementation of an
RefreshAndLock() method in every object, which requeries the properties and
selects the affected rows with SELECT FOR UPDATE NOWAIT, so other users get
an error message while trying to read.

I assume that this a very basic problem. Do you have any useful hints? All
books that I have talk a lot about Oracle or a lot about Builder, but the
interaction in an object based environment isn't explained. BTW: I can't use
Oracle's Object Option because is is not licensed in my company.

Thanks,
Thomas



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.