Fast reading?

Thomas Flemming tf at ttqv.com
Sat Apr 10 04:48:35 CDT 2010


Good Morning,


>> to write large amount of data into the database there is:
>
>> "INSERT INTO [mytable] (f1, f2, f3, ... ) VALUES ( :1, :2, :3, ...)"
>
>> which is very fast.
>
>> Is there also something similar to READ all fields of a record very fast into
>> an array of objects?
>
>> I'm still doing
>
>> cursor.Position = i
>> f1 = cursor.fields("f1").value
>> f2 = cursor.fields("f2").value
>> f3 = cursor.fields("f3").value
>> ...
>
>
>> which is quiet slow...
>
> Probably you are trying to solve your needs in an inappropriate way?
I hope so ;-)

>
> Say, you get a cursor and fill another table with its data.
> So  you  iterate  cursor  records  getting  all  column  values and do
> "inserts"  into another table. Instead of doing something like this at
> once:
>
> insert into another_table select f1,f2... from t1...
>
> Please describe your task and we will find a solution.

Its not filling another table, I just need them into a .net-object/variable.
And so I'm doing

for i =0 to cursor.recordcount
   cursor.Position = i
   f(i).a1 = cursor.fields("f1").value
   f(i).a2 = cursor.fields("f2").value
   f(i).a3 = cursor.fields("f3").value
next


I had the same problem, when writing the data into the table:
for i =0 to f.count
   table.setblank
   table.fields("f1").value = f(i).a1
   table.fields("f2").value = f(i).a2
   table.fields("f3").value = f(i).a3
   table.addrecord
next

which was also quiet slow, but this could be solved with data binding, which 
is much faster:

SqlExecute("INSERT INTO [mytable] (f1, f2,..,fx)
             VALUES ( :1, :2,..,:x)", myarray)

So I was hoping that there is also something with data binding to read a whole 
record quickly into a .net-object/variable

Tom


-- 
/****************************************
**   Dipl.-Ing. Thomas Flemming
**   Software Development
**
**   Touratech AG
**   Auf dem Zimmermann 7-9
**   D-78078 Niedereschach
**
**   mail  tf at ttqv.com
**   fon   +49 (0) 7728 9279-206
**   fax   +49 (0) 7728 9279-29
**
**   http://www.ttqv.com
**   http://www.touratech.de
**
**   ... und immer dem Pfeil nach!
***************************************/


More information about the Valentina mailing list