Copying records between databases

Ruslan Zasukhin sunshine at public.kherson.ua
Wed Jul 30 16:59:33 CDT 2003


on 7/30/03 15:42, Lars Lindholm at lars.lindholm at uneed.se wrote:

> Hi Ruslan,
> 
> I am writing an administration tool for an application that I have
> written using RealBasic and Valentina.
> 
> I have two identical databases (by structure) - sourceDB and
> destinationDB. I have two cursors - sourceCursor with 125 records and
> destinationCursor with 0 records. How do I copy all the records from
> sourceCursor to destinationCursor including all data in all fields?
> 
> I am using RealBasic 4.5.2 on Mac OS X.

Hi Lars,

You need write function with loop on loop
draft:

    fldCount = c1.FieldCount
    recCount = c1.RecCount

    for I = 1 to recCount
        for j = 1 to fldCount

            // here you need copy values

            f1 = c1.GetField(i)
            f2 = c2.GetField(i)

            f1.value = f2.value
        next
    next

As you see problem is that you need also to have inside of loop big switch
on all Valentina types. This is the fastest way for copy.

If you not in hurry at runtime, you can reduce switch because for most of
types except blobs you can use

        f1.SetString( f2.GetString )

For such task will be useful support of Variant type.
In visual BASIC and VCOM this is already implement so for VB developer this
loop will be as simple as
            f1.value = f2.value

And BLOBs of course

-- 
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