Hello friends,
How can we achieve transaction security with DBF?
Are there already ready-made solutions or concepts here?
Maybe also a documentation.
Best regards,
Otto
Transaction security with DBF
- Otto
- Posts: 6403
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 24 times
- Been thanked: 2 times
- Contact:
Transaction security with DBF
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 75 times
- Contact:
Re: Transaction security with DBF
Dear Otto,
The idea is quite simple:
you use a history.dbf where you save all the operations descriptions that you are going to do, before doing them and after doing them, to confirm that they were performed successfully.
If any of those operations fails, then you "undo" what you have done. That is traditionally known as a "rollback".
SQL engines provide such capability but using DBFs we have to do it ourselves, but as you see, it is quite easy
In example: you save this in history.dbf
1. going to save the customer details
2. customer details properly saved
3. going to save the items of the invoice
4. invoice items properly saved
and so on...
if at step 5 (in example) there is an error or an unexpected mistake, then you undo what you did, going backwards from step 4
The idea is quite simple:
you use a history.dbf where you save all the operations descriptions that you are going to do, before doing them and after doing them, to confirm that they were performed successfully.
If any of those operations fails, then you "undo" what you have done. That is traditionally known as a "rollback".
SQL engines provide such capability but using DBFs we have to do it ourselves, but as you see, it is quite easy

In example: you save this in history.dbf
1. going to save the customer details
2. customer details properly saved
3. going to save the items of the invoice
4. invoice items properly saved
and so on...
if at step 5 (in example) there is an error or an unexpected mistake, then you undo what you did, going backwards from step 4
- VictorCasajuana
- Posts: 269
- Joined: Wed Mar 28, 2018 4:38 pm
- Location: Vinaròs
- Has thanked: 1 time
- Contact:
Re: Transaction security with DBF
If you allow me, the logic could be improved to avoid conflicts in multi-user environments. I would add a semaphore to prevent two users from performing a transaction at the same time. The semaphore can be a file on disk, a record in a dbf table, an open socket, or any other signal that a user is performing a transaction.
Enviado desde mi motorola edge 20 mediante Tapatalk
Enviado desde mi motorola edge 20 mediante Tapatalk
--------
¿ Y porque no ?
¿ And why not ?
¿ Y porque no ?
¿ And why not ?
Re: Transaction security with DBF
Dear Otto
Perhaps the integrity of transactions made using the harbor RDDLOG is easier. It should be implemented conveniently, obviously, checking if the RDDLOG is executed in the event that there has been an error in the transaction.
Perhaps the integrity of transactions made using the harbor RDDLOG is easier. It should be implemented conveniently, obviously, checking if the RDDLOG is executed in the event that there has been an error in the transaction.
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
- Otto
- Posts: 6403
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 24 times
- Been thanked: 2 times
- Contact:
Re: Transaction security with DBF
Dear Antonio, Cristobal and Victor,
thank you for your help.
I will expand my database accesses to include these suggestions.
Best regards,
Otto
thank you for your help.
I will expand my database accesses to include these suggestions.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
- Otto
- Posts: 6403
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 24 times
- Been thanked: 2 times
- Contact:
Re: Transaction security with DBF
Hello all,
does someone know if we have in HARBOUR something similar to this?
Best regards,
Otto
does someone know if we have in HARBOUR something similar to this?
Best regards,
Otto
http://www.dbase.com/help/Xbase/IDH_XBA ... BACK__.htm
Show
ROLLBACK( )
Topic group Related topics
Cancels the transaction by undoing all logged changes.
Syntax
ROLLBACK([<database name expC>])
<database name expC>
The name of the database in which to rollback the transaction.
If you began the transaction with BEGINTRANS(<database name expC>), you must issue ROLLBACK(<database name expC>). If instead you issue ROLLBACK( ), dBASE Plus ignores the ROLLBACK( ) statement.
If you began the transaction with BEGINTRANS( ), <database name expC> is an optional ROLLBACK( ) argument. If you include it, it must refer to the same database as the SET DATABASE TO statement that preceded BEGINTRANS( ).
Description
A transaction works by logging all changes. If an error occurs while attempting one of the changes, or the changes need to be undone for some other reason, the transaction is canceled by calling ROLLBACK( ). Otherwise, COMMIT( ) is called to clear the transaction log, thereby indicating that all the changes in the transaction were committed and that the transaction as a whole was posted.
Since new rows have already been written to disk, rows that were added during the transaction are deleted. In the case of DBF tables, the rows are marked as deleted, but are not physically removed from the table. If you want to actually remove them, you can pack the table with PACK. Rows that were just edited are returned to their saved values.
All locks made during a transaction are maintained until the transaction is completed. This ensures that no one else can make any changes until the transaction is committed or abandoned.
For more information on transactions, see BEGINTRANS( ).
OODML
Call the rollback( ) method of the Database object.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
Re: Transaction security with DBF
Hola,
Lo mas parecido a rollback que conozco para archivos .dbf es trabajar con archivos temporales y luego al final hacer un commit
Es una tecnica que mejora mucho la integridad referencial para el caso que se produzca un corte.
En todo caso el rollback, hasta donde yo se no existe en todas las bb.dd. y tampoco deshace totalmente todo
Salu2
***
Hello,
The closest thing I know of to rollback for .dbf files is to work with temporary files and then commit at the end
It is a technique that greatly improves the referential apparatus in the event that a cut occurs.
In any case, the rollback, as far as I know, does not exist in all bb.dd. and it doesn't totally undo everything
Salu2
Lo mas parecido a rollback que conozco para archivos .dbf es trabajar con archivos temporales y luego al final hacer un commit
Es una tecnica que mejora mucho la integridad referencial para el caso que se produzca un corte.
En todo caso el rollback, hasta donde yo se no existe en todas las bb.dd. y tampoco deshace totalmente todo
Salu2
***
Hello,
The closest thing I know of to rollback for .dbf files is to work with temporary files and then commit at the end
It is a technique that greatly improves the referential apparatus in the event that a cut occurs.
In any case, the rollback, as far as I know, does not exist in all bb.dd. and it doesn't totally undo everything
Salu2
- Otto
- Posts: 6403
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 24 times
- Been thanked: 2 times
- Contact:
Re: Transaction security with DBF
Hi,
Thank you very much.
Do you have a simple example to start with?
Best regards,
Otto
Thank you very much.
Do you have a simple example to start with?
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Transaction security with DBF
RDD Built-in ROLLBACK feature:
viewtopic.php?f=3&t=42174
viewtopic.php?f=3&t=42174
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Otto
- Posts: 6403
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 24 times
- Been thanked: 2 times
- Contact:
Re: Transaction security with DBF
Dear Mr. RAo,
Thank you so much for your help.
Best regards,
Otto
Thank you so much for your help.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************