I have two record sets. One is transactions and another is GL posting. I am aiming to create a third table to find out the customers are from which country inflate our GL.
For example GL Table has following fields
Transaction Table has the following fields
Some GLAccounts are straight populated from transaction and some are not. Hence when I take a sum of TxnAmountUSD on GLAccount and TxnCCY and try to match with the sum of BalanceUSD on GLAccount and GLAccountCCY from GL Table it does not match.
The third table I need to create is a reconciliation table and requirement is if I take total of GL table on GLCode it should match with the GLCode in newly crated table (ReconTable). ReconTable should contain all the records from Transaction table. In addition to that new records will be inserted for each GLAccount and CCY combination whose amount does not match with GL.
I am thinking of using CURSOR. The cursor will read value from transaction table and match the figure with GL. If does not match, will create a record with the difference value and insert the ReconTable along with the transaction records. Is this a right approach or is there a better way out?