[V4RB] Copying one record to another Valentina DB

Ruslan Zasukhin sunshine at public.kherson.ua
Fri May 16 12:03:33 CDT 2003


on 5/16/03 11:09 AM, Wonder Fef at wonderfef at noos.fr wrote:

>> perhaps you could give a bit more info (code) so that we can see what
>> needs improving ??
> 
> To give more details, the first database contains the main data of my
> programm, and the second one runs like an archive.
> Let's call them 'maindata.vdb' and 'archive.vdb'

First of all I think in your archive db you should not have any index.

Even if you have some field with unique flag, for archive you can remove it,
Because since your copy data from first db, they are correct.
 
Removing indexes can speed up adding of records.

> All records deleted in the maindata.vdb are copied in the archive.vdb before
> being deleted.
> 
> Dim cursor as Vcursor
> Dim i as integer
> Dim vbo as VBaseObject
> Dim fieldName as string
> 
> Cursor = maindata.SQLSelect("SELECT * from myTable WHERE myBooleanField =
> TRUE)
> 
> If cursor.recordcount = 0 then
>   return
> End if
> 
> 'here I create the same BaseObject from maindata.vdb in archive.vdb if it
> does not exist already.
> 'vbo then equals to the corresponding BaseObject in archive.vdb
> 
> For i = 1 to cursor.fieldcount
> 'here I have code that detect if fields from maindata.vdb exist in
> archive.vdb
> ' it creates fields if necessary
> Next
> 
> ///////// Now I copy the data from the cursor to archive.vdb
> do
>   
>   vbo.SetBlank
>   
>   for i = 1 to cursor.FieldCount
>     
>     fieldname = cursor.Field(i).Name
>     
>     vbo.field(fieldname).SetString(cursor.Field(fieldname).GetString)
>     
>   next
>   
>   vbo.AddRecord()
>   
> loop until cursor.NextRecord = false

All looks correct.

Only way for optimization I see, using not STRING copy,
But simply 

        field1 = field2

It seems V4RB do not allow this.
So I put this on TODO list.

In fact even copy of the whole cursor by single command can be useful here..

And better use cursor for second db also.
Then you will be able in future easy redo that archive is on remote server.

-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list