Transaction security with DBF

Transaction security with DBF

Postby Otto » Wed Aug 31, 2022 7:26 am

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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: Transaction security with DBF

Postby Antonio Linares » Wed Aug 31, 2022 2:51 pm

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Transaction security with DBF

Postby VictorCasajuana » Wed Aug 31, 2022 9:02 pm

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
--------
¿ Y porque no ?
¿ And why not ?
User avatar
VictorCasajuana
 
Posts: 263
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs

Re: Transaction security with DBF

Postby cnavarro » Wed Aug 31, 2022 9:50 pm

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.
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
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Transaction security with DBF

Postby Otto » Wed Aug 31, 2022 10:18 pm

Dear Antonio, Cristobal and Victor,
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
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: Transaction security with DBF

Postby Otto » Fri Sep 09, 2022 6:30 am

Hello all,
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
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: Transaction security with DBF

Postby hmpaquito » Fri Sep 09, 2022 7:15 am

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
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Transaction security with DBF

Postby Otto » Fri Sep 09, 2022 9:00 am

Hi,
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
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: Transaction security with DBF

Postby nageswaragunupudi » Sat Sep 10, 2022 4:36 am

RDD Built-in ROLLBACK feature:
viewtopic.php?f=3&t=42174
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Transaction security with DBF

Postby Otto » Sat Sep 10, 2022 6:14 am

Dear Mr. RAo,
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
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 56 guests