Page 1 of 1

Read from a table and write in other table

Posted: 16.03.2008, 18:04
by fireblade983
Hi!!
I am newbie in these things of data base and have a one doubt.
What I want is to make a query to a table (through the command SELECT FROM...) and then write the results in other table (though the command INSERT INTO...). To make this, do I need 2 Query components (one to read and other to write), or there is a way to save the data read from the query, and then write them in other table, though the same query (ZQUERY) component.

Many thanks, and sorry for my bad english :)

Posted: 17.03.2008, 07:46
by mdaems
It all depends on what and how you want to do it...
- If it's within the same database/server and you just want to copy, you could use the 'insert ... select from...' syntax if that's available for your database. Then a single query component is enough. Just set the SQL property and execute (not open/close).
- If you want to copy within the same database, can use 'insert...select...' but want to allow editing the new values, you can also do this with one query component by executing the copy and set the SQL property to the select query afterwards.
- If you want to copy in the same database but 'insert...select...' isn't available : 1 connection, 2 queries are necessary (which is ugly as you have to move through every field in every row.
- If you want to copy between different servers it becomes even worse. Then you also need 2 connection components.

I hope one of these scenarios may help you.

Mark