Page 1 of 1

copy records table 1 to table 2

PostPosted: Mon Sep 26, 2011 2:11 am
by rogel
hi!

is there a quick way to copy/move ALL records from table1 to table2 than looping through the records(from table1) and transfer it to the next table?

Re: copy records table 1 to table 2

PostPosted: Mon Sep 26, 2011 2:25 am
by ptalbot
Have a look at the rawSQL plugin, where you can use the executeSQL method to copy and notifyDataChange to tell your clients to reload the table based on the new IDs.

Re: copy records table 1 to table 2

PostPosted: Mon Sep 26, 2011 9:12 pm
by rogel
ptalbot wrote:Have a look at the rawSQL plugin, where you can use the executeSQL method to copy and notifyDataChange to tell your clients to reload the table based on the new IDs.


Thanks Patrick.

What I am worried about is the SQL might be database independent. If I were to use servoy, which object would you suggest to use?

Re: copy records table 1 to table 2

PostPosted: Mon Sep 26, 2011 9:40 pm
by ptalbot
You could use transactions (set databaseManager.setAutoSave(false) first) to insert many rows in one go instead of hitting the database for each new record.
You will still need to iterate on the source foundset though, create the new records on the target foundset, fill them with the source data and commitTransaction() after a certain number of rows...

Re: copy records table 1 to table 2

PostPosted: Mon Sep 26, 2011 10:29 pm
by rogel
ptalbot wrote:You could use transactions (set databaseManager.setAutoSave(false) first) to insert many rows in one go instead of hitting the database for each new record.
You will still need to iterate on the source foundset though, create the new records on the target foundset, fill them with the source data and commitTransaction() after a certain number of rows...


start and commit transaction for each table or just one start/commit for the whole function?