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

Record not found after insert, VFP8

Status
Not open for further replies.

wlhbill

Programmer
Aug 25, 2002
20
0
0
US
Hi,
I have an app. that inserts and updates records in a vfp8 database. The database has 2 tables, a header and a detail.
Since adding a record involves inserting a single header and multiple details I start with a BEGIN TRANSACTION, insert the header record, loop through the details and insert them and if all works do an END TRANSACTION. Fairly standard straight forward stuff. However when I try to access the header, the record is not in the table yet. I thought 'buffering'. It is set to record pessimistic. I tried FLUSH and sys(1104). Neither helped. If I close and reopen the table in the app the record is there. It works that way but that seems to me to be kind of a kluge.
Anybody got any suggestions?
Thanks,
Bill
 
You'd better show a piece of code of this transaction here...

Rob.
 

Bill,

However when I try to access the header, the record is not in the table yet.

The answer depends on how you are trying to access the header.

In fact, the record is in the buffer, but it is not physically on disk. If you are using SQL SELECT to get the record, VFP looks at the records physically present on disk, not the records in the buffer. That's why you can't see it.

If you are using native VFP commands to access the record, such as LOCATE, you should be able to retrieve the record OK. But be aware that it won't yet have its correct record number. RECNO() will return a temporary, negative, number.

By the way, FLUSH and SYS(1104) are not the way to deal with this. They deal with different kinds of buffers. Nor does it make a difference whether the locking is optimistic or pessimistic.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top