You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

500 lines
61 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_archiveLogs] Script Date: 9/27/2019 1:30:14 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. CREATE proc [dbo].[proc_archiveLogs]
  9. AS
  10. SET XACT_ABORT ON;
  11. SET NOCOUNT ON;
  12. BEGIN TRY
  13. DECLARE @cutOffDays INT = 5
  14. DECLARE @date DATETIME = CONVERT(VARCHAR, GETDATE()-@cutOffDays, 101)
  15. PRINT CONVERT(VARCHAR, GETDATE(), 109)
  16. EXEC proc_PrintLog 'Moving Data - Started', 'applicationLogs'
  17. BEGIN TRANSACTION
  18. INSERT INTO RemittanceLogData.np.applicationLogs(
  19. rowId,module,logType,tableName,dataId,oldData,newData,createdBy,createdDate
  20. )
  21. SELECT
  22. rowId,module,logType,tableName,dataId,oldData,newData,createdBy,createdDate
  23. FROM applicationLogs WITH(NOLOCK) WHERE createdDate < @date
  24. PRINT @@ROWCOUNT
  25. EXEC proc_PrintLog 'Deleting...',NULL
  26. DELETE FROM applicationLogs WHERE createdDate < @date
  27. COMMIT TRANSACTION
  28. EXEC proc_PrintLog 'applicationLogs', 'apiRequestLog'
  29. BEGIN TRANSACTION
  30. INSERT INTO RemittanceLogData.np.apiRequestLog(
  31. rowId,AGENT_CODE,USER_ID,PASSWORD,AGENT_SESSION_ID,AGENT_TXN_ID,LOCATION_ID,SENDER_NAME,SENDER_GENDER,SENDER_ADDRESS
  32. ,SENDER_MOBILE,SENDER_CITY,SENDER_COUNTRY,SENDER_ID_TYPE,SENDER_ID_NUMBER,SENDER_ID_ISSUE_DATE,SENDER_ID_EXPIRE_DATE
  33. ,SENDER_DATE_OF_BIRTH,RECEIVER_NAME,RECEIVER_ADDRESS,RECEIVER_CONTACT_NUMBER,RECEIVER_CITY,RECEIVER_COUNTRY,TRANSFER_AMOUNT
  34. ,COLLECT_AMT,PAYOUTAMT,PAYMENT_MODE,BANK_ID,BANK_NAME,BANK_BRANCH_NAME,BANK_ACCOUNT_NUMBER,CALC_BY,AUTHORIZED_REQUIRED
  35. ,OUR_SERVICE_CHARGE,EXT_BANK_BRANCH_ID,RECEIVER_IDENTITY_TYPE,RECEIVER_IDENTITY_NUMBER,RECEIVER_RELATION,PAYOUT_AGENT_ID
  36. ,REQUESTED_DATE,TRNDATE,SETTLE_USD_AMT,SETTLE_RATE,CUSTOMER_ID,SOURCE_OF_INCOME,REASON_FOR_REMITTANCE,SENDER_OCCUPATION
  37. ,controlNo,errorCode,errorMsg
  38. )
  39. SELECT
  40. rowId,AGENT_CODE,USER_ID,PASSWORD,AGENT_SESSION_ID,AGENT_TXN_ID,LOCATION_ID,SENDER_NAME,SENDER_GENDER,SENDER_ADDRESS
  41. ,SENDER_MOBILE,SENDER_CITY,SENDER_COUNTRY,SENDER_ID_TYPE,SENDER_ID_NUMBER,SENDER_ID_ISSUE_DATE,SENDER_ID_EXPIRE_DATE
  42. ,SENDER_DATE_OF_BIRTH,RECEIVER_NAME,RECEIVER_ADDRESS,RECEIVER_CONTACT_NUMBER,RECEIVER_CITY,RECEIVER_COUNTRY,TRANSFER_AMOUNT
  43. ,COLLECT_AMT,PAYOUTAMT,PAYMENT_MODE,BANK_ID,BANK_NAME,BANK_BRANCH_NAME,BANK_ACCOUNT_NUMBER,CALC_BY,AUTHORIZED_REQUIRED
  44. ,OUR_SERVICE_CHARGE,EXT_BANK_BRANCH_ID,RECEIVER_IDENTITY_TYPE,RECEIVER_IDENTITY_NUMBER,RECEIVER_RELATION,PAYOUT_AGENT_ID
  45. ,REQUESTED_DATE,TRNDATE,SETTLE_USD_AMT,SETTLE_RATE,CUSTOMER_ID,SOURCE_OF_INCOME,REASON_FOR_REMITTANCE,SENDER_OCCUPATION
  46. ,controlNo,errorCode,errorMsg
  47. FROM apiRequestLog WITH(NOLOCK) WHERE REQUESTED_DATE < @date
  48. PRINT @@ROWCOUNT
  49. EXEC proc_PrintLog 'Deleting...',NULL
  50. DELETE FROM apiRequestLog WHERE REQUESTED_DATE < @date
  51. COMMIT TRANSACTION
  52. EXEC proc_PrintLog 'apiRequestLog', 'siteAccessLog'
  53. BEGIN TRANSACTION
  54. INSERT INTO RemittanceLogData.np.siteAccessLog(
  55. rowId,dcId,dcUserName,ipAddress,accessDate
  56. )
  57. SELECT
  58. rowId,dcId,dcUserName,ipAddress,accessDate
  59. FROM siteAccessLog WITH(NOLOCK) WHERE accessDate < @date
  60. PRINT @@ROWCOUNT
  61. EXEC proc_PrintLog 'Deleting...',NULL
  62. DELETE FROM siteAccessLog WHERE accessDate < @date
  63. COMMIT TRANSACTION
  64. EXEC proc_PrintLog 'siteAccessLog', 'ceAcDepositDownloadLogs'
  65. BEGIN TRANSACTION
  66. INSERT INTO RemittanceLogData.np.ceAcDepositDownloadLogs(
  67. rowId,createdDate,createdBy
  68. )
  69. SELECT
  70. rowId,createdDate,createdBy
  71. FROM ceAcDepositDownloadLogs WITH(NOLOCK) WHERE createdDate < @date
  72. PRINT @@ROWCOUNT
  73. EXEC proc_PrintLog 'Deleting...',NULL
  74. DELETE FROM ceAcDepositDownloadLogs WHERE createdDate < @date
  75. COMMIT TRANSACTION
  76. EXEC proc_PrintLog 'ceAcDepositDownloadLogs', 'apiRequestLogSMA'
  77. BEGIN TRANSACTION
  78. INSERT INTO RemittanceLogData.np.apiRequestLogSMA(
  79. rowId,AGENT_CODE,USER_ID,PASSWORD,AGENT_SESSION_ID,AGENT_TXNID,LOCATION_ID,SENDER_NAME,SENDER_GENDER,SENDER_ADDRESS
  80. ,SENDER_MOBILE,SENDER_CITY,SENDER_COUNTRY,SENDER_ID_TYPE,SENDER_ID_NUMBER,SENDER_ID_ISSUE_DATE,SENDER_ID_EXPIRE_DATE
  81. ,SENDER_DATE_OF_BIRTH,RECEIVER_NAME,RECEIVER_ADDRESS,RECEIVER_CONTACT_NUMBER,RECEIVER_CITY,RECEIVER_COUNTRY,PAYOUT_AMOUNT
  82. ,PAYMENTMODE,BANKID,BANK_ACCOUNT_NUMBER,OUR_SERVICE_CHARGE,EXT_BANK_BRANCH_ID,SETTLE_USD_AMT,SETTLE_RATE,CUSTOMER_ID
  83. ,RECEIVER_RELATION,SOURCE_OF_INCOME,REASON_FOR_REMITTANCE,SENDER_OCCUPATION,REQUEST_DATE,errorCode,errorMsg,controlNo
  84. )
  85. SELECT
  86. rowId,AGENT_CODE,USER_ID,PASSWORD,AGENT_SESSION_ID,AGENT_TXNID,LOCATION_ID,SENDER_NAME,SENDER_GENDER,SENDER_ADDRESS
  87. ,SENDER_MOBILE,SENDER_CITY,SENDER_COUNTRY,SENDER_ID_TYPE,SENDER_ID_NUMBER,SENDER_ID_ISSUE_DATE,SENDER_ID_EXPIRE_DATE
  88. ,SENDER_DATE_OF_BIRTH,RECEIVER_NAME,RECEIVER_ADDRESS,RECEIVER_CONTACT_NUMBER,RECEIVER_CITY,RECEIVER_COUNTRY,PAYOUT_AMOUNT
  89. ,PAYMENTMODE,BANKID,BANK_ACCOUNT_NUMBER,OUR_SERVICE_CHARGE,EXT_BANK_BRANCH_ID,SETTLE_USD_AMT,SETTLE_RATE,CUSTOMER_ID
  90. ,RECEIVER_RELATION,SOURCE_OF_INCOME,REASON_FOR_REMITTANCE,SENDER_OCCUPATION,REQUEST_DATE,errorCode,errorMsg,controlNo
  91. FROM apiRequestLogSMA WITH(NOLOCK) WHERE REQUEST_DATE < @date
  92. PRINT @@ROWCOUNT
  93. EXEC proc_PrintLog 'Deleting...',NULL
  94. DELETE FROM apiRequestLogSMA WHERE REQUEST_DATE < @date
  95. COMMIT TRANSACTION
  96. EXEC proc_PrintLog 'apiRequestLogSMA', 'requestApiLogOther'
  97. BEGIN TRANSACTION
  98. INSERT INTO RemittanceLogData.np.requestApiLogOther(
  99. rowId,AGENT_CODE,USER_ID,PASSWORD,AGENT_SESSION_ID,AGENT_TXN_REF_ID,PAYMENTTYPE,PAYOUT_COUNTRY,PAYOUT_AGENT_ID,REMIT_AMOUNT
  100. ,CALC_BY,REPORT_TYPE,FROM_DATE,TO_DATE,REFNO,CANCEL_REASON,SHOW_INCREMENTAL,REQUEST_DATE,errorCode,errorMsg,METHOD_NAME
  101. )
  102. SELECT
  103. rowId,AGENT_CODE,USER_ID,PASSWORD,AGENT_SESSION_ID,AGENT_TXN_REF_ID,PAYMENTTYPE,PAYOUT_COUNTRY,PAYOUT_AGENT_ID,REMIT_AMOUNT
  104. ,CALC_BY,REPORT_TYPE,FROM_DATE,TO_DATE,REFNO,CANCEL_REASON,SHOW_INCREMENTAL,REQUEST_DATE,errorCode,errorMsg,METHOD_NAME
  105. FROM requestApiLogOther WITH(NOLOCK) WHERE REQUEST_DATE < @date
  106. PRINT @@ROWCOUNT
  107. EXEC proc_PrintLog 'Deleting...',NULL
  108. DELETE FROM requestApiLogOther WHERE REQUEST_DATE < @date
  109. COMMIT TRANSACTION
  110. EXEC proc_PrintLog 'requestApiLogOther', 'soaMonthlyLog'
  111. BEGIN TRANSACTION
  112. INSERT INTO RemittanceLogData.np.soaMonthlyLog(
  113. id,agentId,branchId,fromDate,toDate,soaType,createdDate,message,logType,npMonth,npYear,createdBy
  114. )
  115. SELECT
  116. id,agentId,branchId,fromDate,toDate,soaType,createdDate,message,logType,npMonth,npYear,createdBy
  117. FROM soaMonthlyLog WITH(NOLOCK) WHERE createdDate < @date
  118. PRINT @@ROWCOUNT
  119. EXEC proc_PrintLog 'Deleting...',NULL
  120. DELETE FROM soaMonthlyLog WHERE createdDate < @date
  121. COMMIT TRANSACTION
  122. EXEC proc_PrintLog 'soaMonthlyLog', 'IpAccessLogs'
  123. BEGIN TRANSACTION
  124. INSERT INTO RemittanceLogData.np.IpAccessLogs(
  125. id,ip,fieldValue,createdDate
  126. )
  127. SELECT
  128. id,ip,fieldValue,createdDate
  129. FROM IpAccessLogs WITH(NOLOCK) WHERE createdDate < @date
  130. PRINT @@ROWCOUNT
  131. EXEC proc_PrintLog 'Deleting...',NULL
  132. DELETE FROM IpAccessLogs WHERE createdDate < @date
  133. COMMIT TRANSACTION
  134. EXEC proc_PrintLog 'IpAccessLogs', 'apiRequestLog_GetExRate'
  135. BEGIN TRANSACTION
  136. INSERT INTO RemittanceLogData.np.apiRequestLog_GetExRate(
  137. rowId,AGENT_CODE,USER_ID,PASSWORD,AGENT_SESSION_ID,TRANSFERAMOUNT,PAYMENTMODE,CALC_BY,LOCATION_ID,PAYOUT_COUNTRY
  138. ,errorCode,errorMsg,requestedDate
  139. )
  140. SELECT
  141. rowId,AGENT_CODE,USER_ID,PASSWORD,AGENT_SESSION_ID,TRANSFERAMOUNT,PAYMENTMODE,CALC_BY,LOCATION_ID,PAYOUT_COUNTRY
  142. ,errorCode,errorMsg,requestedDate
  143. FROM apiRequestLog_GetExRate WITH(NOLOCK) WHERE requestedDate < @date
  144. PRINT @@ROWCOUNT
  145. EXEC proc_PrintLog 'Deleting...',NULL
  146. DELETE FROM apiRequestLog_GetExRate WHERE requestedDate < @date
  147. COMMIT TRANSACTION
  148. EXEC proc_PrintLog 'apiRequestLog_GetExRate', 'apiRequestLogPay'
  149. BEGIN TRANSACTION
  150. INSERT INTO RemittanceLogData.np.apiRequestLogPay(
  151. rowId,ACCESSCODE,USERNAME,PASSWORD,REFNO,AGENT_SESSION_ID,PAY_TOKEN_ID,requestedDate,errorCode,errorMsg,remarks
  152. )
  153. SELECT
  154. rowId,ACCESSCODE,USERNAME,PASSWORD,REFNO,AGENT_SESSION_ID,PAY_TOKEN_ID,requestedDate,errorCode,errorMsg,remarks
  155. FROM apiRequestLogPay WITH(NOLOCK) WHERE requestedDate < @date
  156. PRINT @@ROWCOUNT
  157. EXEC proc_PrintLog 'Deleting...',NULL
  158. DELETE FROM apiRequestLogPay WHERE requestedDate < @date
  159. COMMIT TRANSACTION
  160. EXEC proc_PrintLog 'apiRequestLogPay', 'LoginLogs'
  161. BEGIN TRANSACTION
  162. INSERT INTO RemittanceLogData.np.LoginLogs(
  163. rowId,logType,IP,Reason,fieldValue,createdBy,createdDate,UserData,agentId,dcSerialNumber,dcUserName
  164. )
  165. SELECT
  166. rowId,logType,IP,Reason,fieldValue,createdBy,createdDate,UserData,agentId,dcSerialNumber,dcUserName
  167. FROM LoginLogs WITH(NOLOCK) WHERE createdDate < @date
  168. PRINT @@ROWCOUNT
  169. EXEC proc_PrintLog 'Deleting...',NULL
  170. DELETE FROM LoginLogs WHERE createdDate < @date
  171. COMMIT TRANSACTION
  172. EXEC proc_PrintLog 'LoginLogs', 'Logs'
  173. BEGIN TRANSACTION
  174. INSERT INTO RemittanceLogData.np.Logs(
  175. id,errorPage,errorMsg,errorDetails,createdBy,createdDate
  176. )
  177. SELECT
  178. id,errorPage,errorMsg,errorDetails,createdBy,createdDate
  179. FROM Logs WITH(NOLOCK) WHERE createdDate < @date
  180. PRINT @@ROWCOUNT
  181. EXEC proc_PrintLog 'Deleting...',NULL
  182. DELETE FROM Logs WHERE createdDate < @date
  183. COMMIT TRANSACTION
  184. EXEC proc_PrintLog 'Logs', 'txnUploadLog'
  185. BEGIN TRANSACTION
  186. INSERT INTO RemittanceLogData.np.txnUploadLog(
  187. logId,xmlData,xmlErrorData,uploadedBy,uploadedDate,logType,receivingMode,pAgent,pAgentName,pBranch,pBranchName
  188. )
  189. SELECT
  190. logId,xmlData,xmlErrorData,uploadedBy,uploadedDate,logType,receivingMode,pAgent,pAgentName,pBranch,pBranchName
  191. FROM txnUploadLog WITH(NOLOCK) WHERE uploadedDate < @date
  192. PRINT @@ROWCOUNT
  193. EXEC proc_PrintLog 'Deleting...',NULL
  194. DELETE FROM txnUploadLog WHERE uploadedDate < @date
  195. COMMIT TRANSACTION
  196. EXEC proc_PrintLog 'txnUploadLog', 'blacklistLog'
  197. BEGIN TRANSACTION
  198. INSERT INTO RemittanceLogData.np.blacklistLog(
  199. rowId,totalRecord,dataSource,createdBy,createdDate,ofacDate
  200. )
  201. SELECT
  202. rowId,totalRecord,dataSource,createdBy,createdDate,ofacDate
  203. FROM blacklistLog WITH(NOLOCK) WHERE createdDate < @date
  204. PRINT @@ROWCOUNT
  205. EXEC proc_PrintLog 'Deleting...',NULL
  206. DELETE FROM blacklistLog WHERE createdDate < @date
  207. COMMIT TRANSACTION
  208. EXEC proc_PrintLog 'blacklistLog', 'cePayHistory'
  209. BEGIN TRANSACTION
  210. INSERT INTO RemittanceLogData.np.cePayHistory(
  211. rowId,agentId,agentRequestId,beneAddress,beneBankAccountNumber,beneBankBranchCode,beneBankBranchName,beneBankCode
  212. ,beneBankName,beneIdNo,beneName,benePhone,custAddress,custIdDate,custIdNo,custIdType,custName,custNationality,custPhone
  213. ,description,destinationAmount,destinationCurrency,gitNo,paymentMode,purpose,responseCode,settlementCurrency,apiStatus
  214. ,payResponseCode,payResponseMsg,recordStatus,tranPayProcess,createdDate,createdBy,paidDate,paidBy,rContactNo,nativeCountry
  215. ,pBranch,rIdType,rIdNumber,rValidDate,rDob,rAddress,rCity,rOccupation,remarks,rIdPlaceOfIssue,relationType,relativeName
  216. )
  217. SELECT
  218. rowId,agentId,agentRequestId,beneAddress,beneBankAccountNumber,beneBankBranchCode,beneBankBranchName,beneBankCode
  219. ,beneBankName,beneIdNo,beneName,benePhone,custAddress,custIdDate,custIdNo,custIdType,custName,custNationality,custPhone
  220. ,description,destinationAmount,destinationCurrency,gitNo,paymentMode,purpose,responseCode,settlementCurrency,apiStatus
  221. ,payResponseCode,payResponseMsg,recordStatus,tranPayProcess,createdDate,createdBy,paidDate,paidBy,rContactNo,nativeCountry
  222. ,pBranch,rIdType,rIdNumber,rValidDate,rDob,rAddress,rCity,rOccupation,remarks,rIdPlaceOfIssue,relationType,relativeName
  223. FROM cePayHistory WITH(NOLOCK) WHERE createdDate < @date
  224. PRINT @@ROWCOUNT
  225. EXEC proc_PrintLog 'Deleting...',NULL
  226. DELETE FROM cePayHistory WHERE createdDate < @date
  227. COMMIT TRANSACTION
  228. EXEC proc_PrintLog 'cePayHistory', 'ezPayHistory'
  229. BEGIN TRANSACTION
  230. INSERT INTO RemittanceLogData.np.ezPayHistory(
  231. id,TransactionNumber,SecurityNumber,TransactionDate,TypeOfTransaction,TransactionStatus,scCustomerName,scCustomerArabicName
  232. ,scCustomerAddress,scCustomerCardNumber,scCustID,scCustIDType,scCustTelephoneNumber,scCustMobileNumber,scCustNationality
  233. ,scCustEmail,sccustDOB,scCustMessage,scCustOccupation,scRelationship,scCustBankcode,scCustBankShortname,scCustBankName
  234. ,scCustBankBranchcode,scCustBankBranchshortname,scCustBankBranchName,scBranchAddress,scContactPerson,scContactTelephoneNo
  235. ,scCustCountryCode,scCustCountry,tbName,tbArabicName,tbAddress,tbAccountNumber,tbIdNumber,tbIdtype,tbBenBankName
  236. ,tbBenBankBranchName,tbBankShortName,tbBankName,tbBranchShortName,tbBranchName,tbBranchAddress,tbContactPerson
  237. ,tbContactTelephoneNo,tbIBBank,tbIBBranch,tbIBAddress,tbIBBankAccountno,tbIBBankDiffernt,tbIBClearingNumber
  238. ,tbIBClearingType,tbIBSwiftCode,tbTelephoneNumber,tbMobileNumber,tbNationality,tbBenCountry,tbFundSource,tbPin,tbPurpose
  239. ,tbSwiftCode,tbPaymentAgentCode,tbPaymentAgentCountryCode,tbPaymentAgentLocationCode,tbRecipientName,tbRecipientAddress
  240. ,tbRecipientTelephone,tbRecipientMessage,tbReceiverComm,tbTypeOfTransaction,tdFxAmount,tdRate,tdMktRate,tdLocalAmount
  241. ,tdTotalLocalAmount,tdCommissionAmount,tdLocalCurrencyCode,tdFxCurrencyCode,apiStatus,payResponseCode,payResponseMsg
  242. ,recordStatus,tranPayProcess,createdDate,createdBy,paidDate,paidBy,rContactNo,nativeCountry,pBranch,rIdType,rIdNumber
  243. ,rIdPlaceOfIssue,rValidDate,rDob,rAddress,rCity,rOccupation,relationType,relativeName,remarks
  244. )
  245. SELECT
  246. id,TransactionNumber,SecurityNumber,TransactionDate,TypeOfTransaction,TransactionStatus,scCustomerName,scCustomerArabicName
  247. ,scCustomerAddress,scCustomerCardNumber,scCustID,scCustIDType,scCustTelephoneNumber,scCustMobileNumber,scCustNationality
  248. ,scCustEmail,sccustDOB,scCustMessage,scCustOccupation,scRelationship,scCustBankcode,scCustBankShortname,scCustBankName
  249. ,scCustBankBranchcode,scCustBankBranchshortname,scCustBankBranchName,scBranchAddress,scContactPerson,scContactTelephoneNo
  250. ,scCustCountryCode,scCustCountry,tbName,tbArabicName,tbAddress,tbAccountNumber,tbIdNumber,tbIdtype,tbBenBankName
  251. ,tbBenBankBranchName,tbBankShortName,tbBankName,tbBranchShortName,tbBranchName,tbBranchAddress,tbContactPerson
  252. ,tbContactTelephoneNo,tbIBBank,tbIBBranch,tbIBAddress,tbIBBankAccountno,tbIBBankDiffernt,tbIBClearingNumber
  253. ,tbIBClearingType,tbIBSwiftCode,tbTelephoneNumber,tbMobileNumber,tbNationality,tbBenCountry,tbFundSource,tbPin,tbPurpose
  254. ,tbSwiftCode,tbPaymentAgentCode,tbPaymentAgentCountryCode,tbPaymentAgentLocationCode,tbRecipientName,tbRecipientAddress
  255. ,tbRecipientTelephone,tbRecipientMessage,tbReceiverComm,tbTypeOfTransaction,tdFxAmount,tdRate,tdMktRate,tdLocalAmount
  256. ,tdTotalLocalAmount,tdCommissionAmount,tdLocalCurrencyCode,tdFxCurrencyCode,apiStatus,payResponseCode,payResponseMsg
  257. ,recordStatus,tranPayProcess,createdDate,createdBy,paidDate,paidBy,rContactNo,nativeCountry,pBranch,rIdType,rIdNumber
  258. ,rIdPlaceOfIssue,rValidDate,rDob,rAddress,rCity,rOccupation,relationType,relativeName,remarks
  259. FROM ezPayHistory WITH(NOLOCK) WHERE createdDate < @date
  260. PRINT @@ROWCOUNT
  261. EXEC proc_PrintLog 'Deleting...',NULL
  262. DELETE FROM ezPayHistory WHERE createdDate < @date
  263. COMMIT TRANSACTION
  264. EXEC proc_PrintLog 'ezPayHistory', 'globalBankPayHistory'
  265. BEGIN TRANSACTION
  266. INSERT INTO RemittanceLogData.np.globalBankPayHistory(
  267. rowId,radNo,tokenId,benefName,benefTel,benefMobile,benefAddress,benefAccIdNo,benefIdType,senderName,senderAddress,senderTel
  268. ,senderMobile,senderIdType,senderIdNo,remittanceEntryDt,remittanceAuthorizedDt,remitType,rCurrency,pCurrency,pCommission
  269. ,amount,localAmount,exchangeRate,dollarRate,confirmationNo,apiStatus,payResponseCode,payResponseMsg,recordStatus
  270. ,tranPayProcess,createdDate,createdBy,paidDate,paidBy,rContactNo,nativeCountry,pBranch,rIdType,rIdNumber,rValidDate,rDob
  271. ,rAddress,rCity,rOccupation,remarks,rIdPlaceOfIssue,relationType,relativeName
  272. )
  273. SELECT
  274. rowId,radNo,tokenId,benefName,benefTel,benefMobile,benefAddress,benefAccIdNo,benefIdType,senderName,senderAddress,senderTel
  275. ,senderMobile,senderIdType,senderIdNo,remittanceEntryDt,remittanceAuthorizedDt,remitType,rCurrency,pCurrency,pCommission
  276. ,amount,localAmount,exchangeRate,dollarRate,confirmationNo,apiStatus,payResponseCode,payResponseMsg,recordStatus
  277. ,tranPayProcess,createdDate,createdBy,paidDate,paidBy,rContactNo,nativeCountry,pBranch,rIdType,rIdNumber,rValidDate,rDob
  278. ,rAddress,rCity,rOccupation,remarks,rIdPlaceOfIssue,relationType,relativeName
  279. FROM globalBankPayHistory WITH(NOLOCK) WHERE createdDate < @date
  280. PRINT @@ROWCOUNT
  281. EXEC proc_PrintLog 'Deleting...',NULL
  282. DELETE FROM globalBankPayHistory WHERE createdDate < @date
  283. COMMIT TRANSACTION
  284. EXEC proc_PrintLog 'globalBankPayHistory', 'mgPayHistory'
  285. BEGIN TRANSACTION
  286. INSERT INTO RemittanceLogData.np.mgPayHistory(
  287. id,mgiTransactionSessionID,referenceNumber,senderFirstName,senderMiddleName,senderLastName,senderLastName2,senderHomePhone
  288. ,senderAddress,senderCity,senderZipCode,senderCountry,receiverFirstName,receiverMiddleName,receiverLastName,receiverLastName2
  289. ,agentCheckNumber,agentCheckAmount,agentCheckAuthorizationNumber,customerCheckNumber,customerCheckAmount,okForAgent
  290. ,deliveryOption,transactionStatus,dateTimeSent,receiveCurrency,receiveAmount,receiverCountry,originatingCountry
  291. ,validIndicator,indicativeReceiveAmount,indicativeExchangeRate,originalSendAmount,originalSendCurrency,originalSendFee
  292. ,originalExchangeRate,redirectIndicator,originalReceiveAmount,originalReceiveCurrency,originalReceiveCountry,newSendFee
  293. ,newExchangeRate,newReceiveAmount,newReceiveCurrency,feeDifference,redirectType,notOkForPickupReasonCode
  294. ,minutesUntilOkForPickup,notOkForPickupReasonDescription,message1,message2,receiverIdType,receiverIdNumber
  295. ,receiverValidDate,receiverDob,receiverOccupation,receiverNativeCountry,receiverAddress,receiverCity,receiverZipCode
  296. ,receiverContactNo,recordStatus,tranStatus,createdBy,createdDate,payResponseCode,payResponseMsg,superAgent,superAgentName
  297. ,agent,agentName,branch,branchName,idIssueDate,dynamicFields,remarks,receiverIdIssueCountry,receiverIdIssueState
  298. ,receiverNativeState,pCountry,CreatedDateLocal,relationType,relativeName,rIdPlaceOfIssue,rCountry,rState,rIdCountry
  299. ,rIdState,rAddress,rCity,rIdType,rIdNumber,rDob,rMobile,tranPayProcess
  300. )
  301. SELECT
  302. id,mgiTransactionSessionID,referenceNumber,senderFirstName,senderMiddleName,senderLastName,senderLastName2,senderHomePhone
  303. ,senderAddress,senderCity,senderZipCode,senderCountry,receiverFirstName,receiverMiddleName,receiverLastName,receiverLastName2
  304. ,agentCheckNumber,agentCheckAmount,agentCheckAuthorizationNumber,customerCheckNumber,customerCheckAmount,okForAgent
  305. ,deliveryOption,transactionStatus,dateTimeSent,receiveCurrency,receiveAmount,receiverCountry,originatingCountry
  306. ,validIndicator,indicativeReceiveAmount,indicativeExchangeRate,originalSendAmount,originalSendCurrency,originalSendFee
  307. ,originalExchangeRate,redirectIndicator,originalReceiveAmount,originalReceiveCurrency,originalReceiveCountry,newSendFee
  308. ,newExchangeRate,newReceiveAmount,newReceiveCurrency,feeDifference,redirectType,notOkForPickupReasonCode
  309. ,minutesUntilOkForPickup,notOkForPickupReasonDescription,message1,message2,receiverIdType,receiverIdNumber
  310. ,receiverValidDate,receiverDob,receiverOccupation,receiverNativeCountry,receiverAddress,receiverCity,receiverZipCode
  311. ,receiverContactNo,recordStatus,tranStatus,createdBy,createdDate,payResponseCode,payResponseMsg,superAgent,superAgentName
  312. ,agent,agentName,branch,branchName,idIssueDate,dynamicFields,remarks,receiverIdIssueCountry,receiverIdIssueState
  313. ,receiverNativeState,pCountry,CreatedDateLocal,relationType,relativeName,rIdPlaceOfIssue,rCountry,rState,rIdCountry
  314. ,rIdState,rAddress,rCity,rIdType,rIdNumber,rDob,rMobile,tranPayProcess
  315. FROM mgPayHistory WITH(NOLOCK) WHERE createdDate < @date
  316. PRINT @@ROWCOUNT
  317. EXEC proc_PrintLog 'Deleting...',NULL
  318. DELETE FROM mgPayHistory WHERE createdDate < @date
  319. COMMIT TRANSACTION
  320. EXEC proc_PrintLog 'mgPayHistory', 'riaRemitPayHistory'
  321. BEGIN TRANSACTION
  322. INSERT INTO RemittanceLogData.np.riaRemitPayHistory(
  323. rowId,transRefID,orderFound,pin,orderNo,seqIDRA,orderDate,custNameFirst,custNameLast1,custNameLast2,custAddress,custCity
  324. ,custState,custCountry,custZip,custTelNo,beneNameFirst,beneNameLast1,beneNameLast2,beneAddress,beneCity,beneState,beneCountry
  325. ,beneZip,beneTelNo,beneCurrency,beneAmount,responseDateTimeUTC,confirmationNo,apiStatus,payResponseCode,payResponseMsg
  326. ,recordStatus,tranPayProcess,createdDate,createdBy,paidDate,paidBy,rContactNo,nativeCountry,pBranch,rIdType,rIdNumber
  327. ,rValidDate,rDob,rAddress,rCity,rOccupation,remarks,rIdPlaceOfIssue,relationType,relativeName,PCCommissionCurrency
  328. ,PCCommissionAmount,SeqIDPA,sCountry, rBank, rBankBranch, rAccountNo, rChequeNo, customerId, membershipId, topupMobileNo
  329. )
  330. SELECT
  331. rowId,transRefID,orderFound,pin,orderNo,seqIDRA,orderDate,custNameFirst,custNameLast1,custNameLast2,custAddress,custCity
  332. ,custState,custCountry,custZip,custTelNo,beneNameFirst,beneNameLast1,beneNameLast2,beneAddress,beneCity,beneState,beneCountry
  333. ,beneZip,beneTelNo,beneCurrency,beneAmount,responseDateTimeUTC,confirmationNo,apiStatus,payResponseCode,payResponseMsg
  334. ,recordStatus,tranPayProcess,createdDate,createdBy,paidDate,paidBy,rContactNo,nativeCountry,pBranch,rIdType,rIdNumber
  335. ,rValidDate,rDob,rAddress,rCity,rOccupation,remarks,rIdPlaceOfIssue,relationType,relativeName,PCCommissionCurrency
  336. ,PCCommissionAmount,SeqIDPA,sCountry, rBank, rBankBranch, rAccountNo, rChequeNo, customerId, membershipId, topupMobileNo
  337. FROM riaRemitPayHistory WITH(NOLOCK) WHERE createdDate < @date
  338. PRINT @@ROWCOUNT
  339. EXEC proc_PrintLog 'Deleting...',NULL
  340. DELETE FROM riaRemitPayHistory WHERE createdDate < @date
  341. COMMIT TRANSACTION
  342. EXEC proc_PrintLog 'riaRemitPayHistory', 'xPressTranHistory'
  343. BEGIN TRANSACTION
  344. INSERT INTO RemittanceLogData.np.xPressTranHistory(
  345. rowId,xmwsSessionID,xpin,customerFirstName,customerMiddleName,customerLastName,customerPOBox,customerAddress1
  346. ,customerAddress2,customerAddressCity,customerAddressState,customerAddressCountry,customerAddressZip,customerPhone
  347. ,customerMobile,customerFax,customerEmail,customerDescription,customerOtherInfo,beneficiaryFirstName,beneficiaryMiddleName
  348. ,beneficiaryLastName,beneficiaryIDOtherType,beneficiaryID,beneficiaryPOBox,beneficiaryAddress1,beneficiaryAddress2
  349. ,beneficiaryAddressCity,beneficiaryAddressState,beneficiaryAddressCountry,beneficiaryAddressZip,beneficiaryPhone
  350. ,beneficiaryMobile,beneficiaryFax,beneficiaryEmail,beneficiaryTestQuestion,beneficiaryTestAnswer,messageToBeneficiary
  351. ,beneficiaryDescription,beneficiaryOtherInfo,purposeOfTxn,sourceOfIncome,payoutAmount,payInAmount,commission,tax
  352. ,agentXchgRate,payoutCcyCode,payInCcyCode,payoutDate,payinDate,sendingAgentCode,sendingAgentName,receivingAgentCode
  353. ,receivingAgentName,sendingCountry,receiveCountry,transactionMode,accountName,accountNo,bankName,bankBranchName,returnCode
  354. ,returnMsg,recordStatus,tranPayProcess,createdBy,createdDate,txnByHo,branchId,payResponseCode,payResponseMsg,rIdType
  355. ,rIdNumber,rPlaceOfIssue,rRelationType,rRelativeName,rContactNo,rIssuedDate,rValidDate,membershipId,customerId
  356. )
  357. SELECT
  358. rowId,xmwsSessionID,xpin,customerFirstName,customerMiddleName,customerLastName,customerPOBox,customerAddress1
  359. ,customerAddress2,customerAddressCity,customerAddressState,customerAddressCountry,customerAddressZip,customerPhone
  360. ,customerMobile,customerFax,customerEmail,customerDescription,customerOtherInfo,beneficiaryFirstName,beneficiaryMiddleName
  361. ,beneficiaryLastName,beneficiaryIDOtherType,beneficiaryID,beneficiaryPOBox,beneficiaryAddress1,beneficiaryAddress2
  362. ,beneficiaryAddressCity,beneficiaryAddressState,beneficiaryAddressCountry,beneficiaryAddressZip,beneficiaryPhone
  363. ,beneficiaryMobile,beneficiaryFax,beneficiaryEmail,beneficiaryTestQuestion,beneficiaryTestAnswer,messageToBeneficiary
  364. ,beneficiaryDescription,beneficiaryOtherInfo,purposeOfTxn,sourceOfIncome,payoutAmount,payInAmount,commission,tax
  365. ,agentXchgRate,payoutCcyCode,payInCcyCode,payoutDate,payinDate,sendingAgentCode,sendingAgentName,receivingAgentCode
  366. ,receivingAgentName,sendingCountry,receiveCountry,transactionMode,accountName,accountNo,bankName,bankBranchName,returnCode
  367. ,returnMsg,recordStatus,tranPayProcess,createdBy,createdDate,txnByHo,branchId,payResponseCode,payResponseMsg,rIdType
  368. ,rIdNumber,rPlaceOfIssue,rRelationType,rRelativeName,rContactNo,rIssuedDate,rValidDate,membershipId,customerId
  369. FROM xPressTranHistory WITH(NOLOCK) WHERE createdDate < @date
  370. PRINT @@ROWCOUNT
  371. EXEC proc_PrintLog 'Deleting...',NULL
  372. DELETE FROM xPressTranHistory WHERE createdDate < @date
  373. COMMIT TRANSACTION
  374. EXEC proc_PrintLog 'xPressTranHistory', 'exRateCalcHistory'
  375. BEGIN TRANSACTION
  376. SET IDENTITY_INSERT FastMoneyPro_remit_Archive.dbo.[exRateCalcHistory] ON
  377. INSERT INTO FastMoneyPro_remit_Archive.dbo.[exRateCalcHistory](
  378. FOREX_SESSION_ID, AGENT_TXN_REF_ID, AGENT_CODE, [USER_ID], serviceCharge, pAmt, customerRate, sCurrCostRate
  379. ,sCurrHoMargin, sCurrAgentMargin, pCurrCostRate, pCurrHoMargin, pCurrAgentMargin, agentCrossSettRate
  380. ,treasuryTolerance, customerPremium, sharingValue, sharingType, createdDate, isExpired, rowId,msrepl_tran_version
  381. )
  382. SELECT
  383. FOREX_SESSION_ID, AGENT_TXN_REF_ID, AGENT_CODE, [USER_ID], serviceCharge, pAmt, customerRate, sCurrCostRate
  384. ,sCurrHoMargin, sCurrAgentMargin, pCurrCostRate, pCurrHoMargin, pCurrAgentMargin, agentCrossSettRate
  385. ,treasuryTolerance, customerPremium, sharingValue, sharingType, createdDate, isExpired, rowId,msrepl_tran_version
  386. FROM [exRateCalcHistory] (NOLOCK)
  387. WHERE createdDate < @date
  388. PRINT @@ROWCOUNT
  389. SET IDENTITY_INSERT FastMoneyPro_remit_Archive.dbo.[exRateCalcHistory] OFF
  390. EXEC proc_PrintLog 'Deleting...',NULL
  391. DELETE FROM [exRateCalcHistory] WHERE createdDate < @date
  392. COMMIT TRANSACTION
  393. EXEC proc_PrintLog 'exRateCalcHistory', 'icPayHistory'
  394. BEGIN TRANSACTION
  395. INSERT INTO RemittanceLogData.np.icPayHistory(
  396. rowId, ICTC_Number, Agent_OrderNumber, Remitter_Name, Remitter_Address, Remitter_IDType, Remitter_IDDtl, Originating_Country
  397. ,Delivery_Mode, Paying_Amount, PayingAgent_CommShare, Paying_Currency, Paying_Agent, Paying_AgentName, Beneficiary_Name
  398. ,Beneficiary_Address, Beneficiary_City, Destination_Country, Beneficiary_TelNo, Beneficiary_MobileNo, Expected_BenefID
  399. ,Bank_Address, Bank_Account_Number, Bank_Name, Purpose_Remit, Message_PayeeBranch, Bank_BranchCode, Settlement_Rate
  400. ,PrinSettlement_Amount, Transaction_SentDate, apiStatus, payResponseCode, payResponseMsg, recordStatus, tranPayProcess
  401. ,createdDate, createdBy, paidDate, paidBy, rContactNo, nativeCountry, pBranch, rIdType, rIdNumber, rValidDate, rDob
  402. ,rAddress, rCity, rOccupation, remarks, relationship, rIdPlaceOfIssue, relationType, relativeName, rBank, rBankBranch
  403. ,rAccountNo, rChequeNo, topupMobileNo, customerId, membershipId
  404. )
  405. SELECT
  406. rowId, ICTC_Number, Agent_OrderNumber, Remitter_Name, Remitter_Address, Remitter_IDType, Remitter_IDDtl, Originating_Country
  407. ,Delivery_Mode, Paying_Amount, PayingAgent_CommShare, Paying_Currency, Paying_Agent, Paying_AgentName, Beneficiary_Name
  408. ,Beneficiary_Address, Beneficiary_City, Destination_Country, Beneficiary_TelNo, Beneficiary_MobileNo, Expected_BenefID
  409. ,Bank_Address, Bank_Account_Number, Bank_Name, Purpose_Remit, Message_PayeeBranch, Bank_BranchCode, Settlement_Rate
  410. ,PrinSettlement_Amount, Transaction_SentDate, apiStatus, payResponseCode, payResponseMsg, recordStatus, tranPayProcess
  411. ,createdDate, createdBy, paidDate, paidBy, rContactNo, nativeCountry, pBranch, rIdType, rIdNumber, rValidDate, rDob
  412. ,rAddress, rCity, rOccupation, remarks, relationship, rIdPlaceOfIssue, relationType, relativeName, rBank, rBankBranch
  413. ,rAccountNo, rChequeNo, topupMobileNo, customerId, membershipId
  414. FROM icPayHistory WITH(NOLOCK) WHERE createdDate < @date
  415. PRINT @@ROWCOUNT
  416. EXEC proc_PrintLog 'Deleting...',NULL
  417. DELETE FROM icPayHistory WHERE createdDate < @date
  418. COMMIT TRANSACTION
  419. EXEC proc_PrintLog 'icPayHistory', 'cePayHistory_v2'
  420. BEGIN TRANSACTION
  421. INSERT INTO RemittanceLogData.np.cePayHistory_v2(
  422. rowId, ceNumber, originatingAgentRefNum, senderName, senderCountry, senderAgentCode, senderAgentName, senderMobileNumber
  423. ,senderMessageToBeneficiary, txnCreatedDate, receiverName, receiverMobile, payoutCurrencyCode, payoutCurrencyName
  424. ,sentAmount, charges, finalPayoutAmount, receiverAccountNumber, receiverIbanNumber, senderAddress, receiverAddress
  425. ,senderIdType, senderIdNumber, senderIdDateType, senderIdDate, districtId, districtName, serviceId, benBankCode
  426. ,benBankName, benBranchCode, benBranchName, benAccountType, benEftCode, agentCode, responseCode, responseDesc
  427. ,userId, recordStatus, tranPayProcess, createdDate, createdBy, paidBy, paidDate, pBranch, rIdType, rIdNumber
  428. ,rIdPlaceOfIssue, rValidDate, rDob, rAddress, rCity, rOccupation, rContactNo, nativeCountry, relationType, relativeName
  429. ,remarks, payResponseCode, payResponseMsg, rBank, rBankBranch, rAccountNo, rChequeNo, topupMobileNo, customerId
  430. ,membershipId
  431. )
  432. SELECT
  433. rowId, ceNumber, originatingAgentRefNum, senderName, senderCountry, senderAgentCode, senderAgentName, senderMobileNumber
  434. ,senderMessageToBeneficiary, txnCreatedDate, receiverName, receiverMobile, payoutCurrencyCode, payoutCurrencyName
  435. ,sentAmount, charges, finalPayoutAmount, receiverAccountNumber, receiverIbanNumber, senderAddress, receiverAddress
  436. ,senderIdType, senderIdNumber, senderIdDateType, senderIdDate, districtId, districtName, serviceId, benBankCode
  437. ,benBankName, benBranchCode, benBranchName, benAccountType, benEftCode, agentCode, responseCode, responseDesc
  438. ,userId, recordStatus, tranPayProcess, createdDate, createdBy, paidBy, paidDate, pBranch, rIdType, rIdNumber
  439. ,rIdPlaceOfIssue, rValidDate, rDob, rAddress, rCity, rOccupation, rContactNo, nativeCountry, relationType, relativeName
  440. ,remarks, payResponseCode, payResponseMsg, rBank, rBankBranch, rAccountNo, rChequeNo, topupMobileNo, customerId
  441. ,membershipId
  442. FROM cePayHistory_v2(NOLOCK) WHERE createdDate < @date
  443. PRINT @@ROWCOUNT
  444. EXEC proc_PrintLog 'Deleting...',NULL
  445. DELETE FROM cePayHistory_v2 WHERE createdDate < @date
  446. COMMIT TRANSACTION
  447. EXEC proc_PrintLog NULL, 'Moving Data - Completed'
  448. SELECT '0' errorCode, 'Log(s) archived successfully' msg, NULL id
  449. END TRY
  450. BEGIN CATCH
  451. IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION
  452. SELECT '1' rrrorCode, ERROR_MESSAGE() msg, NULL id
  453. END CATCH
  454. GO