Database question

User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Database question

Post 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
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post 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
demont frank
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Post 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

User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post 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
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post 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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post 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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post 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
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post 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.
Marcelo Via Giglio
Posts: 1033
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Post 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.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post 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
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post 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.
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Marcelo,
does TPS work with dbf-files or only with the ADS own files?
Regards,
Otto
Marcelo Via Giglio
Posts: 1033
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Post 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
Post Reply