Copying a table

To copy a table from one database server to another:

  1. Create a connection object and establish the connection to the source database.
  2. Create a SELECT command for the connection.
  3. Retrieve the data to be copied.
  4. Create a connection object and establish the connection to for the destination database server.
  5. Create a parameterized INSERT command for bulk insert.
  6. Execute the SQL command to copy the selected data.
This example shows how to copy the data from a table on one database server into a table on another database server.

      {
          TSQLStandardDBProtocolSQLNet15 sqlNet;
          TSQLStandardDataStoreOracle7 oracle7;
          TSQLStandardConnectionHandle dbc(sqlNet, oracle7);
    dbc.LogonStep(1, TSQLLogonStep( TStandardText("t:129.213.80.90:SAMP"), TStandardText("auser"), TStandardText("apassword"))); TSQLCommandHandle selectCmd = dbc.CreateSQLCommand(TStandardText( "SELECT EMPNO, PROJECTNAME FROM Project"))); selectCmd.Execute(); TRecordSourceHandle recSrc = selectCmd.GetRecordSource(); dbc.LogonStep(1, TSQLLogonStep(TStandardText("other_server"), TStandardText("otheruser"), TStandardText("otherpassword"))); TSQLCommandHandle insertCmd = dbc.CreateSQLCommand(TStandardText( "INSERT INTO Project VALUES(?,?)")); insertCmd.Execute(recSrc); }


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker