Commits changes made to a buffered row, a buffered table, cursor, or cursor adapter.

TABLEUPDATE( [nRows [, lForce]] [, cTableAlias | nWorkArea] [, cErrorArray] )

Parameters

nRows

Specifies which changes made to the table or cursor should be committed.

NoteNote

Visual FoxPro enables Optimistic Row Buffering by default for those cursors associated with a CursorAdapter object.

The following table describes the values for nRows.

nRows Description

0

If row or table buffering is enabled, commit only the changes made to the current row in the cursor. (Default)

When working with CursorAdapter objects, Visual FoxPro executes the appropriate command in the InsertCmd, UpdateCmd, or DeleteCmd property for that row only.

1

If table buffering is enabled, commit changes made to all records to the table or cursor.

If row buffering is enabled, commit only changes made to the current record in the table or cursor.

When working with CursorAdapter objects, Visual FoxPro executes the appropriate commands in the InsertCmd, UpdateCmd, and DeleteCmd properties for each affected row.

2

Commit changes made to the table or cursor in the same manner as when nRows = 1. However, an error does not occur when a change cannot be committed. Visual FoxPro continues to process any remaining records in the table or cursor.

If cErrorArray is included, an array containing error information is created when an error occurs.

For compatibility with previous Visual FoxPro applications, the nRows parameter also accepts False (.F.) and True (.T.) instead of 0 and 1 respectively.

When specifying 0 or 1 for nRows, the record pointer remains on the record where changes could not be committed. To determine why the changes could not be committed, use the AERROR( ) function.

When working with CursorAdapter objects and specifying 1 or 2 for nRows, all changes made to the cursor in the following CursorAdapter events must be committed during the same call to TABLEUPDATE( ) unless an error occurs:

  • BeforeInsert

  • AfterInsert

  • BeforeDelete

  • AfterDelete

  • BeforeUpdate

  • AfterUpdate

Visual FoxPro passes the values of nRows to the CursorAdapter BeforeCursorUpdate event.

lForce

Determines whether Visual FoxPro overwrites changes made to the table or cursor by another user on a network.

The following table describes the values for lForce.

lForce Description

False (.F.)

Commits changes to the table or cursor, starting with the first record and continuing towards the end of the table or cursor. (Default)

True (.T.)

Overwrites any changes made to the table or cursor by another user on a network. The WHERE clause uses only key fields.

When working with CursorAdapter objects, Visual FoxPro passes the value of lForce to the following CursorAdapter events:

cTableAlias

Specifies the alias of the table or cursor in which the changes are committed. If you include a table or cursor alias, you must include the lForce argument.

nWorkArea

Specifies the work area of the table or cursor in which the changes are committed. If you include a work area, you must include the lForce argument.

cErrorArray

Specifies the name of an array created when nRows = 2 and changes to a record cannot be committed. The array contains a single column containing the record numbers of the records for which changes could not be committed. If you include an array name, you must include either a table or cursor alias cTableAlias or a work area number nWorkArea.

NoteNote

If an error other than a simple commit error occurs while updating records, the first element of cErrorArray will contain –1, and you can then use AERROR( ) to determine the why the changes could not be committed.

Visual FoxPro passes the value of cErrorArray, when it exists, to the CursorAdapter AfterCursorUpdate event.

Expand imageReturn Value

Expand imageRemarks

Expand imageExample

Expand imageSee Also