Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace dont work in very rare occasions

Status
Not open for further replies.

eys

Programmer
Joined
Mar 5, 2001
Messages
28
Location
MX
I have an application that uses a prg central code to update quantity on hand of several items.

This works well, this program process about 35,000 records in a month, BUT SOMETIMES, the replace is not making its job and 7 or 8 records does are not replaced in a month.

I was triyng to find a path or event that makes this happen, even I known exactly when the program mistakes via a logfile when this happen.

I quit the buffering for this table, and I dont known what else to do to ensure flush the changes to disk.

Theres part of code:

SELECT salarti
v_saldoante = salarti.saluncomp

REPLACE salarti.saluncomp WITH salarti.saluncomp + (movinv.movunidad * movinv.movfacuni + movinv.movunibon) IN salarti

FLUSH
v_saldodesp = salarti.saluncomp

SELECT salarti

IF v_saldoante = v_saldodesp .AND. (movinv.movunidad * movinv.movfacuni + movinv.movunibon) != 0 && This means that after the update, wasn't updated.

= GRA_ERROR() && Write log with error detail
ELSE
FLUSH
GO TOP
ENDIF

1. Even in a document with several records, the program process all of them OK, except the one that makes the problem (and always appear in the log file).

2. Is there a way to write on stone the replace? (bulletproof)

3. Do I have to move the pointer or what?

Please, I known there are friendly genius minds listen my prayers, give me a hand.

Jose Carlos Sanchez.

PS. By the way, excuse the span-glish and thanks to Ramani, Tom and all the guys that helps before.
 
HI
Are you using Buffereing ?
If yes ... then..
You can add the following code in the above.. after
[COLOR=/blue]
SELECT salarti
v_saldoante = salarti.saluncomp
REPLACE salarti.saluncomp WITH salarti.saluncomp +;
(movinv.movunidad*movinv.movfacuni + ;
movinv.movunibon) IN salarti
[COLOR=/]
with the following code.
[COLOR=/red]
SET MULTILOCKS ON && If not already done
SELECT salarti
=CURSORSETPROP("Buffering",3)
Local nowAdd, lToAdd
lToAdd = .t.
nowAdd = movinv.movunidad*movinv.movfacuni + ;
movinv.movunibon)
DO WHILE lToAdd
** The update was not successful
** since some one else has locked the record/file
** and every chance the values are changed
REPLACE saluncomp WITH saluncomp + nowAdd
IF TABLEUPDATE()
lToAdd = .f.
ENDIF
ENDDO
[COLOR=/]

This will enure the records are written correctly.


Are you using Buffereing ?
If NO ... then..
[COLOR=/red]
SET MULTILOCKS ON && If not already done
SELECT salarti
Local nowAdd, lToAdd
lToAdd = .t.
nowAdd = movinv.movunidad*movinv.movfacuni + ;
movinv.movunibon)
DO WHILE lToAdd
IF RLOCK()
REPLACE saluncomp WITH saluncomp + nowAdd
lToAdd = .f.
ELSE
** The update was not successful.. Looped back
ENDIF
ENDDO
[COLOR=/]


Beware of the pifall.. that some on could lock for very long time.. if you have taken care of such issues. In that case, you can put a messagebox in the above code to do a total reversal or dont exit the loop...that is your babe :-)
Hope this helps :-) ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
HI.. Sorry reposted for readability

Are you using Buffereing ?
If yes ... then..
You can add the following code in the above.. after
[COLOR=/green]
SELECT salarti
v_saldoante = salarti.saluncomp
REPLACE salarti.saluncomp WITH salarti.saluncomp +;
(movinv.movunidad*movinv.movfacuni + ;
movinv.movunibon) IN salarti
[COLOR=/]
with the following code.
[COLOR=/blue]
SET MULTILOCKS ON && If not already done
SELECT salarti
=CURSORSETPROP("Buffering",3)
Local nowAdd, lToAdd
lToAdd = .t.
nowAdd = movinv.movunidad*movinv.movfacuni + ;
movinv.movunibon)
DO WHILE lToAdd
** The update was not successful
** since some one else has locked the record/file
** and every chance the values are changed
REPLACE saluncomp WITH saluncomp + nowAdd
IF TABLEUPDATE()
lToAdd = .f.
ENDIF
ENDDO
[COLOR=/]

This will enure the records are written correctly.


Are you using Buffereing ?
If NO ... then..
[COLOR=/blue]
SET MULTILOCKS ON && If not already done
SELECT salarti
Local nowAdd, lToAdd
lToAdd = .t.
nowAdd = movinv.movunidad*movinv.movfacuni + ;
movinv.movunibon)
DO WHILE lToAdd
IF RLOCK()
REPLACE saluncomp WITH saluncomp + nowAdd
lToAdd = .f.
ELSE
** The update was not successful.. Looped back
ENDIF
ENDDO
[COLOR=/]

Beware of the pifall.. that some on could lock for very long time.. if you have taken care of such issues. In that case, you can put a messagebox in the above code to do a total reversal or dont exit the loop...that is your babe
Hope this helps :-) ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top