I am writing an ETL job, in c#, using Rhino ETL
I have a database on ServerA. This has 2 tables:
(example)
tblOrder
- OrderID
- CustomerName
- CustomerEmailAddress
- Transferred
tblOrderLine
- OrderID
- ProductID
- ProductName
- Price
On ServerB, it has a an identical table (orders are transferred from Web, to our backend system)
Using RhinoETL, my InputCommandOperation currently looks like:
class ReadOrdersFromWebDB : InputCommandOperation
{
public ReadOrdersFromServerA(ConnectionStringSettings connectionStringSettings)
: base(connectionStringSettings) { }
protected override Row CreateRowFromReader(IDataReader reader)
{
return Row.FromReader(reader);
}
protected override void PrepareCommand(IDbCommand cmd)
{
cmd.CommandText = "SELECT TOP 10 * FROM tblOrders WHERE Transferred = 0";
}
}
Since there are no transforms to do at this stage, my OutputCommandOperation will look like this:
class WriteOrdersToServerB : OutputCommandOperation
{
protected override void PrepareCommand(IDbCommand cmd, Row row)
{
cmd.CommandText =
@"INSERT INTO etc...........";
}
}
What I want to do is modify this process, to also get the tblOrderLine detail from ServerA - if possible, without doings a seconds query on the db (join) I'm keen to avoid having a "Transferred" column on the tblOrderLine table, and would prefer modifying the InputCommand to include a join..
How does the insert operation work after having a Join in the InputCommand? Is this even possible?