Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiuser transaction processing 2

Status
Not open for further replies.

vfpguy

Programmer
May 15, 2001
4
US
I work at a small company with about 80 employees. We are currently using FoxPro 2.6 (and making the transition to Visual FoxPro).
When we use the database on the server, often the tables are locked, so users often get on the intercom to say "If you are 'parked' in the [any] file, please exit..."
Regarding this, I know that this has been solved already through transaction processing, but I don't understand how. With multiple users using the same database, how does it update - do their views update right then, and only specific records are locked?...
Furthermore, applying this subject to my company, most of our applications have parent-child relationship. The child table is the many table. So, do all of those records need to be locked to be viewed by one user?
How can we improve this? How can I fix things so users won't get on the intercom to ask another user to get out. Perhaps the other user hasn't even been 'parked' in the file that long!
Thank you very much for you help.

 
My trick is to have 4 fields in the record.
update , L
updated (d)
updatet c, 8 &&time
updateby , c (8)
with VFP the date/time fields can become one field

When a record is created/edited Update = .t. , update by = username, updated = date(), updatet = time()
when you exit the record update = .f.
you now have a record of the last person the touched the record

now when you land on the record
If update
= messagebox("record is opened by "+ updateby)
else
do form xxxx
endif David W. Grewe
Dave@internationalbid.com
ICQ VFP ActiveList #46145644
 
The record locking is required only when a record need to be updated/modified/added. All viewing does not need any file/record locking. The simple thumb rule is that never lock a record and leave the control to the user with lock on. The easiest way is to build the locking function at the time of appending/modifying the record in the navigation class and always use this class for all modifications.
Example of a good SaveButton Click event of the navigation class...
Save.CickEvent
==============
LOCAL llSaved
SELECT (ThisForm.cPapaAlias)
m.llSaved=ThisForm.AddChk() && check if record can be processed
IF !EMPTY(ALLTRIM(ThisForm.cPapaKey)) .AND. llSaved
WAIT WINDOW ;
" Please wait while the data is being Saved " NOWAIT
BEGIN TRANSACTION
IF SEEK(ThisForm.cPapaKey)
IF ThisForm.lIsNewMaster
MESSAGEBOX("Record with same ID just now added by some other user."+chr(13)+"This addition aborted. Retry with new ID",0+48,"You are Saved")
ELSE
GATHER MEMVAR MEMO
IF !EMPTY(ThisForm.cChildAlias)
ThisForm.ChildUpdate()
ENDIF
WAIT WINDOW " Data Saved " NOWAIT
ENDIF
ELSE
INSERT INTO (ALIAS()) FROM MEMVAR
IF !EMPTY(ThisForm.cChildAlias)
ThisForm.ChildUpdate()
ENDIF
WAIT WINDOW " Data Saved " NOWAIT
ENDIF
FLUSH
END TRANSACTION
This.Parent.cmdAdd.Enabled = .T.
This.Parent.Setme()
ELSE
** ThisForm.Text1.SetFocus
ENDIF
All the functions called within the routine shall be simple adding routines depending on each of the form conditions and shall return without any user interaction. This way no one will ever lock the record to avoid others waiting for ever. Also SET MULTILOCKS ON and SET REPROCESS TO AUTOMATIC so that when a user has locked for those few milli seconds of update, others will automatically wait to access those records, in case a clash arise.

Hope the above gives you the insight for Transaction processing. Believe it or not, a complete mutiuser Financial accouting system with inventory control and invoicing for several stations has only one Save button and has the code only once in the entire application.. which carries the BEGIN TRANSACTION/END TRANSACTION loop and works perfectly well.

This is the real advantage of SubClassing in VFP.
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top