×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Replace dont work in very rare occasions

Replace dont work in very rare occasions

Replace dont work in very rare occasions

(OP)
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.

RE: Replace dont work in very rare occasions

HI
Are you using Buffereing ?
If yes ... then..  
You can add the following code in the above.. after

   SELECT salarti
   v_saldoante = salarti.saluncomp
   REPLACE salarti.saluncomp WITH salarti.saluncomp +;
           (movinv.movunidad*movinv.movfacuni + ;
            movinv.movunibon) IN salarti

with the following code.

   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


This will enure the records are written correctly.


Are you using Buffereing ?
If NO ... then..  

   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



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
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

RE: Replace dont work in very rare occasions

HI.. Sorry reposted for readability

Are you using Buffereing ?
If yes ... then..  
You can add the following code in the above.. after

   SELECT salarti
   v_saldoante = salarti.saluncomp
   REPLACE salarti.saluncomp WITH salarti.saluncomp +;
           (movinv.movunidad*movinv.movfacuni + ;
            movinv.movunibon) IN salarti

with the following code.

   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


This will enure the records are written correctly.


Are you using Buffereing ?
If NO ... then..  

   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


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
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close