Merging two Table Records
Hi guys,some times we need to merge two records within one line of table,
so to do this you can use following code, here for example i am using VendTabel and try to merge two vendors whose a/c no is 5001 and 5002 within 5001.
//we will explore how to correct such a situation by merging two records including
//all their related transactions. For the demonstration, we will merge two vendor accounts 5001
//and 5002 into a single one, that is, 5001.
static void VendAccountMerge(Args _args)
{
VendTable vendTable;
VendTable vendTableDelete;
PurchJournalAutoSummary jourSummary;
#define.vend('5001')
#define.vendDelete('5002')
;
ttsbegin;
delete_from jourSummary
where jourSummary.VendAccount == #vendDelete;
select firstonly forupdate vendTableDelete
where vendTableDelete.AccountNum == #vendDelete;
select firstonly forupdate vendTable
where vendTable.AccountNum == #vend;
vendTableDelete.merge(vendTable);
vendTable.doUpdate();
vendTableDelete.doDelete();
ttscommit;
}
Be Careful to use this job/Query coz it directly effect your data base
Comments
Post a Comment