I have a script which rebuilds the balances on a file called "Bookings" from 2 related tables , being "Charges" and "Payments". The script loops through all bookings and then via related records in the "charges" and "Payments" table.
The script will work for around about 16 records and then I get the message:-
idx1.query_create() could not create temporary file
I have read about problems in relation to the number of queries open , but as you will see from the code I frop each query after each sub - loop. Interesting If I remove one of the sub loop s(eg: idx2 query loop) . It runs to completion.
Can anyone help?
'*** rebuild Account Balances ****
t=table.open ("Bookings")
t1=table.open ("Charges")
t2=table.open ("Payments")
t.index_primary_put("Bookno")
t.fetch_first()
while .not. t.fetch_eof()
'*** Update Status Bar ****
nCount=nCount +1
statusbar.Percent(nCount,nMax)
'**** Get Charges *****
nCharges=0
nChargeTax=0
nPayments=0
query.order = "bookno"
query.filter = "bookno = " + str(t.bookno)
idx1=t1.query_create()
t1.fetch_first()
while .not. t1.fetch_eof()
nCharges=nCharges+t1.Amount
nChargeTax=nChargeTax+t1.tax
t1.fetch_next()
end while
idx1.drop()
'*** Payments ****
query.order="bookno"
query.filter = "bookno=" + str(t.bookno)
idx2=t2.query_create()
t2.fetch_first()
while .not. t2.fetch_eof()
nPayments=nPayments+t2.amount
t2.fetch_next()
end while
idx2.drop()
t.change_begin(.t.)
t.charges = nCharges
t.Chargestax = nChargeTax
t.Payments = nPayments
t.change_end(.t.)
t.fetch_next()
end while
t.Recalc_CalcFields()
t2.close()
t1.close()
t.close()
The script will work for around about 16 records and then I get the message:-
idx1.query_create() could not create temporary file
I have read about problems in relation to the number of queries open , but as you will see from the code I frop each query after each sub - loop. Interesting If I remove one of the sub loop s(eg: idx2 query loop) . It runs to completion.
Can anyone help?
'*** rebuild Account Balances ****
t=table.open ("Bookings")
t1=table.open ("Charges")
t2=table.open ("Payments")
t.index_primary_put("Bookno")
t.fetch_first()
while .not. t.fetch_eof()
'*** Update Status Bar ****
nCount=nCount +1
statusbar.Percent(nCount,nMax)
'**** Get Charges *****
nCharges=0
nChargeTax=0
nPayments=0
query.order = "bookno"
query.filter = "bookno = " + str(t.bookno)
idx1=t1.query_create()
t1.fetch_first()
while .not. t1.fetch_eof()
nCharges=nCharges+t1.Amount
nChargeTax=nChargeTax+t1.tax
t1.fetch_next()
end while
idx1.drop()
'*** Payments ****
query.order="bookno"
query.filter = "bookno=" + str(t.bookno)
idx2=t2.query_create()
t2.fetch_first()
while .not. t2.fetch_eof()
nPayments=nPayments+t2.amount
t2.fetch_next()
end while
idx2.drop()
t.change_begin(.t.)
t.charges = nCharges
t.Chargestax = nChargeTax
t.Payments = nPayments
t.change_end(.t.)
t.fetch_next()
end while
t.Recalc_CalcFields()
t2.close()
t1.close()
t.close()
Comment