TABLEUPDATE()

From Recital Documentation Wiki
Jump to: navigation, search

Purpose

Function to commit buffered changes


Syntax

TABLEUPDATE(<expL1> | <expN> [, <expL2> [, <workarea | alias> [, <arrayname>]]])


See Also

CURSORGETPROP(), CURSORSETPROP(), CURVAL(), GETFLDSTATE(), OLDVAL(), TABLEREVERT(), SETFLDSTATE()


Description

The TABLEUPDATE() function is used to commit changes during buffered processing. If <expL1> is .T. or <expN> 1 (True) TABLEREVERT() applies to all rows under table buffering and the current row under row buffering. If <expL1> is .F. or <expN> 0 (False) TABLEREVERT() only applies to the current row. If <expN> is 2, updates are processed as if <expN> is 1, but encountering an error does not stop the update. Instead, error information is stored in the array, <arrayname>, if specified. The optional <expL2> determines whether changes made by another user are overwritten (.T.) or not (.F.).

If the optional <workarea | alias> is specified, then the function will operate in the required location.


Example

close databases
clear
set exclusive off
open database southwind
use customers
// Set to known value before start
replace customerid with "ALFKI"
 
cursorsetprop("Buffering", 5, "customers")
messagebox("Buffering set to " +etos(cursorgetprop("Buffering")))
 
? "Original customerid value: " + customerid
? "Curval(): " + curval("customerid")
? "Oldval(): " + oldval("customerid")
? "Fieldstate at start: " + getfldstate("customerid")
 
replace customerid WITH "RECIT"
 
// Alter in another session
! recital -c "update southwind\!customers set customerid = 'MULTI' where recno() = 1"
? "Someone else just updated the record!"
? "New customerid value: " +  customerid 
? "Curval(): " + curval("customerid")
? "Oldval(): " + oldval("customerid")
? "Fieldstate after replace: " + getfldstate("customerid")
tablerevert(.T.)
 
? "Reverted customerid value: " +  customerid
? "Curval(): " + curval("customerid")
? "Oldval(): " + oldval("customerid")
? "Fieldstate after revert: " + getfldstate("customerid")
 
replace customerid WITH "RECIT"
? "New customerid value: " +  customerid 
tableupdate(.T.)
? "Updated customerid value: " +  customerid
? "Curval(): " + curval("customerid")
? "Oldval(): " + oldval("customerid")
? "Fieldstate after replace and update: " + getfldstate("customerid")
?


Products

Recital, Recital Server