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

scanning through buffered records 1

Status
Not open for further replies.

vj

Programmer
Nov 18, 2000
58
0
0
MU
hi everyone,

i have a form with a grid on it ... and the grid it pointing to a table xyz.dbf ... in the forms data environment i have set the xyz.dbf's buffermodeoverride to 5. ... i'll do the =tableupdate(.t.) on a save button to save those entries.
now on the form iam entering records into the grid and since these new records being entered into the grid are still not committed ... is there a way to scan through these new uncommitted records ? since a select query will fetch records from xys.dbf for only records that have been committed !

thankx
Vijay
 
Hi Vijay,

You need the GETNEXTMODIFIED() function. Basically, you call this function in a loop until it returns 0. Each time round the loop, it returns the record number of the next uncommitted record.

The Help topic for this function contains a useful example.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
To include new, buffered records in a query result, add the clause WITH (Buffering=.T.) in the FROM part of the query:

Code:
SELECT ... ;
  FROM MyTable WITH (Buffering=.T.) ;
    ...

Tamar
 
It's only the query, which does not see the uncommitted data without (Buffering=.T.) or SET SQLBUFFERING ON. A SCAN/ENDSCAN loop and direct access of table.field will display/read the buffered data. You'll need CURVAL() to read the DBF as sql does and OLDVAL() to see what you loaded, so actually this new feature is only needed for SQL queries on the table including buffered data, the "normal" access of table.field always sees the buffered data.

We lived without SQLBUFFERING most of the time and I tend to avoid that feature, as it caused reproducable C5 errors.

Bye, Olaf.
 
There's another possibility if you're dealing ONLY with newly added buffered rows. A new row that is buffered gets a negative record number so you can

Code:
Scan For Recno() < 0
   * do whatever
Endscan

This is HIGHLY specialized. It WILL NOT WORK with buffered editing in existing records.

In 20 years I've used it exactly once, and it predated WITH BUFFERING = .T., but boy was it just the right thing at the time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top