General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
Dear Jim
According to your suggestion I have developed the following module but there is some thing wrong with me.
There is a table PID.DBF with one field PID and two records
1st record - last PID No.(Personnal Identification No.)
2nd record - last Bill No.
another table BILL.DBF which contain Bill record.
To generate unique PID No. and unique Bill No. I have written the
following routine where if PID No. already exists then it is not generated.
*============
select 0
do while .t.
use pid alias pid EXCLUSIVE
if USED("pid")
exit
endif
enddo
if len(alltrim(temp.pid)) = 0
select pid
go top
m.lastpid = pid.pid
mpd = val(substr(m.lastpid,2,6))
m.pdno="P"+padl(alltrim(str(mpd+1,6,0)),6,"0")
replace pid.pid with m.pdno
else
m.pdno = temp.pid
endif
select pid
go bottom
mbno = val(left(pid.pid,6))
m.bno=padl(alltrim(str(mbno+1,6,0)),6,"0")
replace pid.pid with m.bno
select pid
use
*===============
then BILL.DBF is open exclusive and record is added with bill no. - m.bno
The programme is excuted from three node simultaneously and approx 700 bill are generated daily.
But in a day there will surely 3 or 4 duplicate bill no.
Can you tell me where I am wrong.
Thanking you
Aritra Roychoudhury
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only