EVValueAccess.forAdd parameter question

Ivan Smahin ivan_smahin at paradigmasoft.com
Wed Oct 29 04:07:42 CDT 2014


On Oct 29, 2014, at 10:35, François Van Lerberghe <frvanlerberghe at gmail.com> wrote:

> Hello,
> 
> What's the exact scope of the EVValueAccess.forAdd parameter used with
> VCursor.SetBlank ?
> 
> The wiki say "Valentina will not save copies of previous field values."
> 
> Is this statement valid for the whole life of VCursor or only for the next
> command (Vcursor.AddRecord for example).
> 
> In other words, may I
> - create a Vcursor with several fields
> - use setBlank with this EVValueAccess.forAdd  parameter
> - Add some records
> - Go to some records (Vcursor.Position = n)
> - and finally, update *one* field of one or several records of this Vcursor
> ?
> 

Sure you can. The first operation is "adding new record":

curs.SetBlank( forAdd )
	curs.LongField(1).Value = 1
	curs.ShortField(2).Value= 2
res = curs.AddRecord()

The second operation is "updating existed record":

curs.currentRecord = res 
	curs.LongField(1).Value = 100
	curs.ShortField(2).Value = 200
curs.UpdateRecord()


Following Wiki:
Parameter inAccess can be used to speed up SetBlank() if you add records. In this case you can specify its value forAdd, so Valentina will not save copies of previouse field values. In the same time you can always use the default value forUpdate and everyhting will work correctly.

It is about some optimization to speed up adding new record only.
BTW, there is a case to call "curs.SetBlank( forUpdate )":
Assume you want to update all the fields of existed record but provide the values for few fields only. And you want that rest of the fields have their default values (if defined) or "empty" (empty for string, NULL for nullable fields, zero for numeric and so on...)
So you do:

curs.SetBlank( forUpdate ) -- prepare buffer of "empty/default" values for all fields
curs.currentRecord = res 
	curs.LongField(1).Value = 100 -- change value for first field only. 
curs.UpdateRecord()

"forUpdate" param is for internally "rollback" values after error during update record.

-- 
Best regards,
Ivan Smahin
Senior Software Engineer
Paradigma Software, Inc
Valentina - The Ultra-Fast Database
http://www.valentina-db.com



More information about the Valentina mailing list