Difference between revisions of "OLDVAL()"

From Lianjapedia
Jump to: navigation, search
m (Text replace - "Recital" to "Lianja")
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Function to to return original values for fields that may have been modified but not updated
 
Function to to return original values for fields that may have been modified but not updated
 
  
 
==Syntax==
 
==Syntax==
 
OLDVAL(<expC> [, <workarea | alias>])
 
OLDVAL(<expC> [, <workarea | alias>])
 
  
 
==See Also==
 
==See Also==
 
[[CURSORGETPROP()]], [[CURSORSETPROP()]], [[CURVAL()]], [[GETFLDSTATE()]], [[TABLEREVERT()]], [[TABLEUPDATE()]], [[SETFLDSTATE()]]
 
[[CURSORGETPROP()]], [[CURSORSETPROP()]], [[CURVAL()]], [[GETFLDSTATE()]], [[TABLEREVERT()]], [[TABLEUPDATE()]], [[SETFLDSTATE()]]
 
  
 
==Description==
 
==Description==
Line 15: Line 12:
  
 
If the optional <workarea | alias> is specified, then the function will operate in the required location.  
 
If the optional <workarea | alias> is specified, then the function will operate in the required location.  
 
  
 
==Example==
 
==Example==
Line 35: Line 31:
 
? "Fieldstate at start: " + getfldstate("customerid")
 
? "Fieldstate at start: " + getfldstate("customerid")
  
replace customerid WITH "RECIT"
+
replace customerid WITH "LIANJ"
  
 
// Alter in another session
 
// Alter in another session
! recital -c "update southwind\!customers set customerid = 'MULTI' where recno() = 1"
+
// update southwind!customers set customerid = 'MULTI' where recno() = 1
 
? "Someone else just updated the record!"
 
? "Someone else just updated the record!"
 
? "New customerid value: " +  customerid  
 
? "New customerid value: " +  customerid  
Line 51: Line 47:
 
? "Fieldstate after revert: " + getfldstate("customerid")
 
? "Fieldstate after revert: " + getfldstate("customerid")
  
replace customerid WITH "RECIT"
+
replace customerid WITH "LIANJ"
 
? "New customerid value: " +  customerid  
 
? "New customerid value: " +  customerid  
 
tableupdate(.T.)
 
tableupdate(.T.)
Line 61: Line 57:
 
</code>
 
</code>
  
 
==Products==
 
Lianja, Lianja Server
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
[[Category:Buffered Processing]]
+
[[Category:Cursor Functions]]
[[Category:Buffered Processing Functions]]
+

Latest revision as of 13:38, 19 May 2014

Purpose

Function to to return original values for fields that may have been modified but not updated

Syntax

OLDVAL(<expC> [, <workarea | alias>])

See Also

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

Description

The OLDVAL() function can be used during buffered processing to return one or more field values from a record as they were prior to any uncommitted changes. The field or fields to be checked are specified in <expC>.

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 "LIANJ"
 
// Alter in another session
// 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 "LIANJ"
? "New customerid value: " +  customerid 
tableupdate(.T.)
? "Updated customerid value: " +  customerid
? "Curval(): " + curval("customerid")
? "Oldval(): " + oldval("customerid")
? "Fieldstate after replace and update: " + getfldstate("customerid")
?