We Recommend

Beginning XML Beginning XML
The perfect resource for beginning XML programmers, this guidebook shows you what XML is, how to use it, and what technologies surround it. The authors build on the strengths of previous editions while covering the latest changes in the XML landscape such as XQuery, RSS and Atom, and Ajax.


Posted By

ejboy on 02/23/07


Tagged

database xml jdbc etl scriptella


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

ejboy


Copy table from one database to another


Published in: XML 


URL: http://scriptella.javaforge.com

This Scriptella ETL script copies all rows from SrcTable to DestTable. SrcTable contains the following columns: id, firstname, lastname DestTable contains the following columns: id, name The name column of the DestTable is produced by a concatenation of firstname and lastname from the SrcTable This example demonstrates HSQLDB-To-Oracle copy procedure, although it works between virtually any databases.

  1. <!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
  2. <etl>
  3. <connection id="in" driver="hsqldb" url="jdbc:hsqldb:file:demo"
  4. classpath="hsqldb.jar" user="sa"/>
  5. <connection id="out" driver="oracle" url="jdbc:oracle:thin:@localhost:1521:ORCL"
  6. classpath="ojdbc14.jar" user="scott" password="tiger"/>
  7. <!-- Copy all table rows from one to another database -->
  8. <query connection-id="in">
  9. SELECT * FROM Src_Table --Selects all rows
  10. <!-- For each row executes insert -->
  11. <script connection-id="out">
  12. INSERT INTO Dest_Table(ID, Name)
  13. VALUES (?id,?{first_name+' '+last_name})
  14. </script>
  15. </query>
  16. </etl>

Report this snippet 

You need to login to post a comment.