RE: Populate SalesOrderId from RetailTransactionTable
Ok, so you already have ChannelReferenceId in your table before running this code.
I also noticed a third table, onlineOrderStatusTable in your code. What is that one?
In general your code doesn't even seem to compile.
Let's go through your existing code one more time. I added comments to describe what it does on each line:
public void updateStatus()
{
RetailTransactionTable retailTransactionTable ;
MyTable myTable; // myTable is introduced but never selected. So, all fields will be empty
tts begin // Compiler error would occur.
// The next line will select retailTransactionTable where ChannelReference is empty
select * from retailTransactionTable where retailTransactionTable.ChannelReferenceId == myTable.ChannelReferenceId;
// Now you set empty value in retailTransactionTable.SalesId. Not much impact since it's anyway just an empty table buffer, and you never insert or update anything
retailTransactionTable.salesOrderId = myTable.SalesOrder;
// Finally, you insert "onlineOrderStatusTable". I assume this is some third table that you have introduced outside the code that you shared with us
onlineOrderStatusTable.insert();
ttscommit;
}
I'm still not sure about your requirement, your description is unfortunately a bit unclear.
If I understand correctly, here are the facts and requirements:
1) MyTable already contains records that have ChannelTransactionId
2) You would like to copy SalesOrderId value from RetailTransactionTable to MyTable, using ChannelTransactionId as a key between these tables.
Then the code would look something like this:
MyTable myTable;
RetailTransactionTable retailTransactionTable;
ttsbegin;
update_recordset myTable
setting SalesOrder = retailTransactionTable.SalesOrderId
join retailTransactionTable
where retailTransactionTable.ChannelReferenceId == myTable.ChannelReferenceId;
ttscommit;
The question remains, why do you need to duplicate this data.