Clone DataSet (TZQuery) in Delphi 7

1
Hello, I have a delphi application that does the following: It makes a query in the PostGreSQL database using the Zeos TZQuery / TZConnection components, then it traverses the result by writing it to another table, that table with columns identical to those of the generated columns of the previous query.

It works, however, the amount of records is too large and traversing all those records 1 to 1 takes a lot of time. Here's how I resolved to split this work by traversing the DataSet using threads, but I stopped at a problem that is as follows:

I can not create new instances of the table (DataSet), so I can not work on parallelism. Does anyone have an idea how to solve this?

Excerpt from how I'm running and how I tried to run respectively:

qry := TZQuery.Create(nil);
qry := DM.Qry_Levantamento;
--------------
qry := TZQuery.Create(nil);
qry.Assign(DM.Qry_Levantamento);

I also thought about doing all of this for Query, but I have not taken it further because I do not know if you can apply this SQL parallelism. Thanks!

    
asked by anonymous 04.07.2018 / 18:43

1 answer

3

Good morning Rafael. If I understood correctly what you want .. :) one of the solutions would be to use a direct command from sql .. It would look like ..:

Insert into TABELA_DESTINO Select * from TABELA_ORIGEM  Where TABELA_ORIGEM.CAMPO = 'XXX'

I tested this command in PARADOX and MYSQL, it worked perfectly and fast. Any doubt is just talking.
Hope this helps. Hugs ..:)

    
05.07.2018 / 12:22