Read from a table and write in other table

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
fireblade983
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 27.02.2008, 00:15

Read from a table and write in other table

Post 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 :)
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
Image
Post Reply