Monday, November 5, 2012

Merging two records


//Open the AOT, create a new job named LedgerReasonMerge with the
//following code:

static void LedgerReasonMerge(Args _args)
{
ReasonTable reasonTableDelete;
ReasonTable reasonTable;
ttsBegin;
select firstOnly forUpdate reasonTableDelete
where reasonTableDelete.Reason == 'COUNTER';
select firstOnly forUpdate reasonTable
where reasonTable.Reason == 'AUCTION';
reasonTableDelete.merge(reasonTable);
reasonTable.doUpdate();
reasonTableDelete.doDelete();
ttsCommit;
}



//The key method in this recipe is the merge()method. It will ensure that all data from one
//record will be copied into the second one and all related transactions will be updated to
//reflect the change.

No comments: