I'm trying to replicate in C# the following simple SQL statement:
INSERT INTO T1 SELECT * FROM T2;
One thing to notice here is that T1 and T2 are not only in different schemas and DB's, but also in different servers, and dblinks are NOT an option.
All the documentation and examples I've found online use explicit column names, which I don't know at design time (I rely on the caller of my script to make sure T1 and T2 are compatible; if not, I just return an error).
Here is the basic code I've been playing around with; the reading part works just fine, but the writing part doesn't work at all (no exceptions thrown, the execution completes fine but T2 doesn't get populated):
OracleDataAdapter od = new OracleDataAdapter();
tr.SourceConnection.Open();
OracleCommand selectCommand = BuildCommand(tr.SourceConnection, string.Format("SELECT * FROM {0}", tr.SourceTable));
od.SelectCommand = selectCommand;
DataTable srcTb = new DataTable(tr.SourceTable);
od.Fill(srcTb);
tr.SourceConnection.Close();
// Everything works well up to here, so "SELECT * FROM {0}" seems to be the right query
tr.TargetConnection.Open();
DataTable tgtTb = new DataTable(tr.TargetTable);
OracleCommand insertCommand = BuildCommand(tr.TargetConnection, string.Format("INSERT INTO {0}", tr.TargetTable));
od.InsertCommand = insertCommand;
od.Update(tgtTb);
tr.TargetConnection.Close();
// The data doesn't get pushed to the DB table; what do I need to use instead of "INSERT INTO {0}"?
// Or do I need a totally different approach?
Thanks a lot in advance!