Database question

Database question

Postby Otto » Fri Oct 26, 2007 6:37 am

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: 6327
Joined: Fri Oct 07, 2005 7:07 pm

Re: Database question

Postby Enrico Maria Giordano » Fri Oct 26, 2007 10:04 am

APPEND FROM? Record by record?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Otto » Fri Oct 26, 2007 10:26 am

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

Postby demont frank » Fri Oct 26, 2007 11:09 am

Otto ,

To append safely records i use :

Code: Select all  Expand view
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

demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Postby Otto » Fri Oct 26, 2007 11:50 am

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
Otto
 
Posts: 6327
Joined: Fri Oct 07, 2005 7:07 pm

Postby Enrico Maria Giordano » Fri Oct 26, 2007 12:09 pm

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

Postby Otto » Fri Oct 26, 2007 2:03 pm

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
Otto
 
Posts: 6327
Joined: Fri Oct 07, 2005 7:07 pm

Postby James Bott » Fri Oct 26, 2007 2:26 pm

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: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby James Bott » Fri Oct 26, 2007 2:55 pm

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

Postby Otto » Fri Oct 26, 2007 4:50 pm

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
Otto
 
Posts: 6327
Joined: Fri Oct 07, 2005 7:07 pm

Postby Marcelo Via Giglio » Fri Oct 26, 2007 6:21 pm

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

Postby Enrico Maria Giordano » Fri Oct 26, 2007 6:48 pm

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

Postby Otto » Fri Oct 26, 2007 6:55 pm

> 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: 6327
Joined: Fri Oct 07, 2005 7:07 pm

Postby Otto » Fri Oct 26, 2007 7:09 pm

Marcelo,
does TPS work with dbf-files or only with the ADS own files?
Regards,
Otto
User avatar
Otto
 
Posts: 6327
Joined: Fri Oct 07, 2005 7:07 pm

Postby Marcelo Via Giglio » Fri Oct 26, 2007 7:15 pm

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 53 guests

cron