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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Refresh and Set reprocess

Status
Not open for further replies.

mstrcmtr

Programmer
Nov 14, 2007
103
PK
Using Following setting in Multi-User Environment

SET REFRESH TO 5,3
SET REPROCESS TO 5 SECONDS

Tablebuffering set to 5

CounteTbl has only 1 record with 1 Field N(6)

e.g. CounterTbl current value is 31

e.g. Both Users working on Sale Invoice and they both save invoice at same time User-1 first succeeded in locking CounterTbl and then advance the CounterTbl value from 31 to 32 and unlock CounterTbl but for User-2 after many many tries still Countertbl showing 31 instead of 32

What's wrong here ?

1. Lock counter table by Flock()

2. Lock Successfully then get present no of counter table

3. Update header and detail Sale tables with this counter no

4. Advance Counter No by 1 in counter table

5. llCntrSccss = TABLEUPDATE(0,.T.,'CounterTbl')

6. FLUSH IN CounterTbl

7. UNLOCK IN CounterTbl


 
I've seen changes take a long time, not just seconds, due to network quirks/settings or switches. There is a lot of caching going on. Your best bet is to close and reopen the counter table before incrementing the value. Or you might make use of autoint, the way I propose it in faq184-7743, the way VFP handles the counter in the table header makes it pretty safe and unbreakable.

Of course that depends on using VFP8 or 9.

Bye, Olaf.
 
PS: You don't have to apply the idea to make it a counter for all IDs. I fear, though, as you don't already simply use an autoinc field for the invoice number, you work with an older VFP version.

You may switch to getting a numeric sequence from elsewhere, eg SQL Server, if there is one available anyway.

Bye, Olaf.
 
From your old posting found this can it work in my case

SET REFRESH TO 0,-1

Using VFP-9-SP2 and also using Autoinc field in my sale header and detail table but in Autoinc the no sequence break because if user cancel the invoice then it jump the no.

Customer's require continuity in Computer Sale Invoice No. therefore using old method
 
OK, you may try, but my first recommendation today is to close and reopen the counter DBF.

Anyway, the gaps in number sequences was an issue in a very similar case for me, too. If numbers are generated quickly cancel also doesn't help, because the next number already is used when a clerk cancels his current. Then you also get a gap. For that matter we introduced a number caching table from which you really draw the next number available. If some number is put back, it can be used to fill the gap. And the best is to stornate instead of cancel or even delete, that means a number stays and the sequence isn't broken. That's how classical booking works, too for documetation purposes.

Of course as you flock some clerk wanting an invoice ID has to wait, but actually you would need to flock the counter table until a clerk not only got his invoice number, but really saved the invoice bindingly.

Bye, Olaf.
 
Try this on multiple pc at same time in lan

SET REFRESH TO 5,3
SET REPROCESS TO 5 SECONDS
IF !FILE("temp.dbf")
create table temp.dbf (line01s c(4),line02c n(15))
INDEX on line01s TAG one
ENDIF
CLOSE DATABASES
USE temp.dbf INDEX temp.cdx ORDER 1 IN 0 ALIAS "temp"
SELECT temp
IF RECCOUNT()=0
INSERT INTO temp VALUES ("LAST",0)
ENDIF
FOR ii=1 TO 100
SEEK "LAST"
IF RLOCK()
VouNo=line02c
replace line02c WITH VouNo+1
VouNo=line02c
UNLOCK
ENDIF
INSERT INTO temp (line01s,line02c) VALUES ("DATA",VouNo)
WAIT WINDOW TIMEOUT .1 "Adding data"
ENDFOR
RETURN
 
Copy your code in prg and then run it append 101 records in temp dbf and the last record is with data (Last,101 )

I have 3 tables

1. Header
2. Detail
3. Counter

Header & detail has 1 to many relation both have different fields

Please explain what is for temp table & how can i use this in my scenario
 
1. Header (Invoice_no N(6) , InvDate D , PartyCode C(8) , InvAmt N(12,2))

2. Detail (Invoice_No N(6) , ItemNo N(6) , Qty N(6) , Rate N(9,2) , Amt N(10,2) )

3. Counter (CounterNo N(6))
 
Please explain how close and re-open the counter table before Flocking it
 
In this example, Once user1 got the number <1> further processing/updating will be with <1>. and similarly user2 will get number <2> and he would be processed by <2>. Both users can not get same number. Should we post sample code ?
 
SET REFRESH TO 5,3
SET REPROCESS TO 5 SECONDS
IF !FILE("InvHD.dbf")
CREATE TABLE InvHD.dbf (Invoice_no N(6),InvDate D,PartyCode C(8),InvAmt N(12,2))
ENDIF
IF !FILE("InvDE.dbf")
CREATE TABLE InvDE.dbf (Invoice_No N(6),ItemNo N(6),Qty N(6),Rate N(9,2),Amt N(10,2))
ENDIF
IF !FILE("InvCO.dbf")
CREATE TABLE InvCO.dbf (CounterNo N(6))
ENDIF
CLOSE DATABASES
USE InvHD IN 0 ALIAS "InvHD"
USE InvDE IN 0 ALIAS "InvDE"
USE InvCO IN 0 ALIAS "InvCO"
SELECT InvCO
IF RECCOUNT()=0
INSERT INTO InvCO VALUES (0)
ENDIF
FOR ii=1 TO 100
SELECT InvCO
IF RLOCK()
VouNo=CounterNo
replace CounterNo WITH VouNo+1
VouNo=CounterNo
UNLOCK
ENDIF
INSERT INTO InvHD VALUES (VouNo,DATE(),SYS(3),VAL(SYS(3)))
INSERT INTO InvDE VALUES (VouNo,VAL(SYS(3)),VAL(SYS(3)),VAL(SYS(3)),VAL(SYS(3)))
WAIT WINDOW TIMEOUT .1 "Adding data"
ENDFOR
 
>Please explain how close and re-open the counter table before Flocking it

Well, I assume you can code in VFP:

Code:
USE IN CounterTbl && close counter table
FLUSH FORCE &&optionally flush
USE CounterTbl IN 0 && reopen counter table

Bye, Olaf.


 
...on top of that you might need to unbind any control displaying the CounterTbl field.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top