Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
7
Erster Beitrag:
vor 8 Jahren, 12 Monaten
Letzter Beitrag:
vor 8 Jahren, 11 Monaten
Beteiligte Autoren:
Paul Ziegler, Fabrice Harari

Locked Records

Startbeitrag von Paul Ziegler am 26.11.2008 18:25

Is the only way a Hyper File record gets locked is with: HLockRecNum?
I have read the Help and just want to verify that Queries, HReadFirst, NReadNext, etc do not automatically lock records.

Also, if I want to put a database into Ready Only for certain clients, I could use HLockFile for all the files and nothing will unlock the file for that client (HFCS) except HUnlockFile?

If I lock a file in HFCS, it is only locked for that client?
If I lock a file, in HF Classic network that file is locked for other users?

Thanks,
Paul

Antworten:

Hi Paul...

It has to be locled explicitely (no function will lock it without YOU asking for it)...

if you lock the file, ONLY the user locking the file will be able to access it...

A lock is for EVERYBODY accessing the file (or locking would have very little purpose), and it's the same in classic or HFCS...

basically you want to lock a record ONLY while you are modifying it (and not while the form is open, only during the save button process), and a file only while you are doing maintenance work on it (if you have a process merging duplicates records by example)

Best regards

Fabrice Harari
WinDev, WebDev, Windev Mobile consulting

von Fabrice Harari - am 26.11.2008 19:24
Fabrice,

Thanks for the reply. It is very helpful to know exactly how the locking is working. In my last design tool, whenever we did a query a record was loaded and locked. The same for some other db functions.

If I only lock the record when I run a Save procedure, what stops another user from opening the same record and doing some modifications at the same time?

Thanks,
Paul

von Paul Ziegler - am 26.11.2008 20:27
Hi Paul...

When working on this problem, you first have to define 'at the same time'...

I personally find that most of the time, blocking a record as soon as a form is open is not acceptable (what happen when the user stays logged and leave for the week end.. On Thursday?)

So what I do is a little more complex, but less intrusive for the users:
- when opening the form, I save the original values
- when the user clicks save, I check if anything was modified
- if not, there is nothing to save, hence no blocking necessary
- if something was modified, I then check the record in the DB
- if it's the same than the original one, I can just block my record and save it
- if the record was modified while I was working, I check what fields were modified outside and by me... If they are different, I just merge the changes, block and modify...
- the only DIFFICULT case is when another user modified the same field(s) than I did...

In that case, 2 different strategies are possible:
- display the conflict and let the user decide (I find that difficult to understand for the user, and anyway, he generally doesn't know any better than always say that HIS changes should win)
- decide once and for all that LAST IN WINS, and therefore write MY modifications in the record...

But of course, that's just me :-)

Best regards

Fabrice Harari
WinDev, WebDev, WinDev Mobile consulting

von Fabrice Harari - am 26.11.2008 21:34
Fabrice,

Thanks for the info. You take good care of your users.

Before when I asked if a record lock was locked to other users, I was not thinking. What I wanted to say was is there an easy way to just set one user to a Read Only status? In my old tool I would set all files to Read Only and it would only affect the Local User.

Thanks,

Paul

von Paul Ziegler - am 26.11.2008 22:37
Hi Paul...

well, you CAN do a hOpen with hRead option, and all add/modify/delete will be impossible, but you will still need to test for the corresponding errors each time your code tries to do something like this...

you could intercept these errors with a when exception of course, but if you procede like that, the user will have no visual clue that he is in read only, and THEN will have an error message (even if it's a pretty one) when he tries to edit something (after he entered all the changes)...

It seems to me that you'd better have a global flag and grey all save button when entering forms, the process would be more user friendly

Best regards

Fabrice Harari
WinDev, WebDev, WinDev Mobile Video Courses

von Fabrice Harari - am 27.11.2008 11:07
Fabrice,

Thanks for the advice. You have been very helpful.

Paul

von Paul Ziegler - am 27.11.2008 14:38
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.