Page 1 of 2
Database question
Posted: Fri Oct 26, 2007 6:37 am
by Otto
What would be a secure way to append a small database ( < 1000 records) to a journal dbf file and
then delete the small database.
Thank in advance
Otto
Re: Database question
Posted: Fri Oct 26, 2007 10:04 am
by Enrico Maria Giordano
APPEND FROM? Record by record?
EMG
Posted: Fri Oct 26, 2007 10:26 am
by Otto
Thank you, Enrico,
>Record by record?
But what it a record fails? How could a “Rollback” be made.
Are there some coding guidelines, examples?
Regards,
Otto
Posted: Fri Oct 26, 2007 11:09 am
by demont frank
Otto ,
To append safely records i use :
Code: Select all
FUNCTION APND(lAdd)
*************
LOCAL cAlias := Alias()
DEFAULT Toevoegen := .F.
DO WHILE .T.
//APPEND BLANK
(cAlias)->(DBAPPEND(! lAdd))
IF ! (cAlias)->(NETERR())
RETU .T.
ELSE
IF msgNoYes("Not appended. Try again (5 sec) ?")
MtrWait("Wait 5 sec","Append again")
ELSE
RETU .F.
END
END
END
RETU .T.
********************************************
proc mtrWait(cMessage,cTitle,nSec)
***************************************
// Wait with oMeter
MsgMeter( { | oMeter, oText, oDlg, lEnd | ;
TestMMt( oMeter, oText, oDlg, @lEnd , nSec ) },;
cMessage , cTitle )
RETURN
function TestMMT( oMeter, oText, oDlg, lEnd , nSec )
*****************************************************
LOCAL start := seconds()
DEFAULT nSec := 5
oMeter:nTotal = nSec //seconds()
DO WHIL seconds() < start + nSec
EVAL({||oMeter:Set(seconds()-start ) , SysRefresh(), ! lEnd })
END
return nil
Posted: Fri Oct 26, 2007 11:50 am
by Otto
Thank you for sharing.
We have a ECR program. There the consumption of a guest is stored in a single dbf file. I the guest checks out the dbf file is added to the file where the sales volume of the whole day is stored.
The question is:
How to be secure that the whole file is imported?
And if something goes wrong to do a roll back in automatic mode.
Regards,
Otto
Posted: Fri Oct 26, 2007 12:09 pm
by Enrico Maria Giordano
Otto wrote:But what it a record fails? How could a “Rollback” be made.
Why do you need to rollback the succesfully appended records?
EMG
Posted: Fri Oct 26, 2007 2:03 pm
by Otto
What if the append is successfully but the delete in the dbf file not?
Example:
Transfer of money from one account to another.
The append is successfully the delete not. Who pays the difference?
Regards,
Otto
Posted: Fri Oct 26, 2007 2:26 pm
by James Bott
Otto,
Did you know that you can lock more than one record at a time?
Lock all the records to be moved, then attempt the append, if the append works, then delete all the locked records. If the append isn't successful, then unlock all the locked records.
James
Posted: Fri Oct 26, 2007 2:55 pm
by James Bott
Otto,
You may find this info useful.
DBAPPEND() Append a new record to the current Lock List
DBRLOCK() Lock the record at the current or specified identity
DBRLOCKLIST() Return an array of the current Lock List
DBRUNLOCK Release all or specified record locks
James
Posted: Fri Oct 26, 2007 4:50 pm
by Otto
Does someone use the Transaction Processing System (TPS) from
Advantage database server?
Regards,
Otto
A Transaction Processing System (TPS) allow an application to perform multiple insert, update, and delete operations to any number of tables with complete confidence that either all of the insert, update, and delete operations will be successful or that none of the operations will occur. In other words, a TPS processes multiple insertions, updates, and deletions as though they were a single operation.
In networked environments, tables and their associated index files are susceptible to corruption if a workstation crashes or a network failure occurs while the tables and index files are being updated. Building an audit trail to monitor these failures is difficult. Developing a method to recover from incomplete updates is even more difficult. Transaction Processing Systems eliminate these problems and protect database integrity by automatically undoing any updates that were performed in the event of workstation or network failure. This leaves a database exactly as it was before a transaction began.
Transaction Processing is not supported in the Advantage Local Server. Use of Advantage Transaction Processing functionality may appear to complete successfully when using Advantage Local Server, but in fact, use of Transaction Processing features will be ignored by Advantage Local Server applications.
See Transaction Processing System (TPS) for a full explanation of the Transaction Processing System available in the Advantage Database Server.
The Advantage Database Server provides the powerful features of a Transaction Processing System (TPS) for your Advantage applications. Advantage TPS allows an application to perform multiple insert, update, and delete operations to any number of tables with complete confidence that either all of the insert, update, and delete operations will be successful or that none of the operations will occur. In other words, Advantage TPS processes multiple insertions, updates, and deletions as though they were a single operation.
Posted: Fri Oct 26, 2007 6:21 pm
by Marcelo Via Giglio
Otto,
TPS work good in ADS, but only in ADS server version, this is main differnece between LOCAL and Server version of ADS, and TPS work only if the record affected in the transaction are locked
regards
Marcelo
Otto wrote:Does someone use the Transaction Processing System (TPS) from
Advantage database server?
Regards,
Otto
A Transaction Processing System (TPS) allow an application to perform multiple insert, update, and delete operations to any number of tables with complete confidence that either all of the insert, update, and delete operations will be successful or that none of the operations will occur. In other words, a TPS processes multiple insertions, updates, and deletions as though they were a single operation.
In networked environments, tables and their associated index files are susceptible to corruption if a workstation crashes or a network failure occurs while the tables and index files are being updated. Building an audit trail to monitor these failures is difficult. Developing a method to recover from incomplete updates is even more difficult. Transaction Processing Systems eliminate these problems and protect database integrity by automatically undoing any updates that were performed in the event of workstation or network failure. This leaves a database exactly as it was before a transaction began.
Transaction Processing is not supported in the Advantage Local Server. Use of Advantage Transaction Processing functionality may appear to complete successfully when using Advantage Local Server, but in fact, use of Transaction Processing features will be ignored by Advantage Local Server applications.
See Transaction Processing System (TPS) for a full explanation of the Transaction Processing System available in the Advantage Database Server.
The Advantage Database Server provides the powerful features of a Transaction Processing System (TPS) for your Advantage applications. Advantage TPS allows an application to perform multiple insert, update, and delete operations to any number of tables with complete confidence that either all of the insert, update, and delete operations will be successful or that none of the operations will occur. In other words, Advantage TPS processes multiple insertions, updates, and deletions as though they were a single operation.
Posted: Fri Oct 26, 2007 6:48 pm
by Enrico Maria Giordano
Otto wrote:What if the append is successfully but the delete in the dbf file not?
You can trap DELETE error and, in the case, delete the appended record.
I really don't see any problem.
EMG
Posted: Fri Oct 26, 2007 6:55 pm
by Otto
> I really don't see any problem.
Please google for:
transaction concepts database
Transaction concepts are one of the main problems of database handling. Therefore dbf files are substituted more and more though SQL tables in bigger applications. There you have start transaction end transaction and roll back.
Here a good starting point:
http://www.cs.utexas.edu/users/dahlin/C ... Gray81.pdf
Please see what ADS says about this:
In networked environments, tables and their associated index files are susceptible to corruption if a workstation crashes or a network failure occurs while the tables and index files are being updated. Building an audit trail to monitor these failures is difficult. Developing a method to recover from incomplete updates is even more difficult. Transaction Processing Systems eliminate these problems and protect database integrity by automatically undoing any updates that were performed in the event of workstation or network failure. This leaves a database exactly as it was before a transaction began.
Posted: Fri Oct 26, 2007 7:09 pm
by Otto
Marcelo,
does TPS work with dbf-files or only with the ADS own files?
Regards,
Otto
Posted: Fri Oct 26, 2007 7:15 pm
by Marcelo Via Giglio
Otto,
ADS work with dbf,ntx,cdx and propietary adt, my experience is with ADT, but I think there are not difference with DBF.
regards
Marcelo
Otto wrote:Marcelo,
does TPS work with dbf-files or only with the ADS own files?
Regards,
Otto