question

priyajadhav985 avatar image
priyajadhav985 asked

I want to replace cursor in from the bellow query

USE [AxisDataWarehouse_UAT]
GO
/****** Object: StoredProcedure [dbo].[msp_GenerateClaimMovementsPCC] Script Date: 1/11/2021 5:20:06 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


--msp_GenerateClaimMovementsPCC 'Axis', 'DataImport', '00005520' , null


ALTER procedure [dbo].[msp_GenerateClaimMovementsPCC]
@Client nvarchar(50),
@Module nvarchar(50),
@BRN nvarchar(50),
@AsAtDate nvarchar(8)


with recompile
as


--##########################################################################
-- Copyright (c) MOORE STEPHENS CONSULTING LIMITED, 2005 All rights reserved
--
-- Object : procedure
-- Name : msp_GenerateClaimMovements.sql
-- Desc : description of procedure
-- Owner : Shirley Sweeney
-- Created : 13/04/2005
--
--##########################################################################
--
-- $Id: msp_GenerateClaimMovements.sql 1.34 2006/03/29 10:58:55Z Phil Exp $
-- $Log: msp_GenerateClaimMovements.sql $
-- Revision 1.34 2006/03/29 10:58:55Z Phil
-- Added AccountingCurrency to exists check.
-- Revision 1.33 2005/07/05 14:18:32Z slam
-- Added msp_UpdateImportControl proc to end of build, this is to ensure LASTBRN is not updated before the Claim Build, and is updated after the Claim Build, otherwise NULL controldates are generated. Also added dateadd 1 day to the AsAtDate2 parameter to derive correct date, mimicking the AsAtDateFrom functionality from msp_GeneratePolicyMovementsControl.
-- Revision 1.32 2005/07/01 08:21:47Z slam
-- Removed null for AsAtDate2
-- Revision 1.31 2005/06/06 13:52:11Z slam
-- Added CASE statements back to the INSERT of CORRECTIONS
-- Revision 1.30 2005/06/06 12:56:10Z slam
-- Corrected financial amounts for INSERTION of CORRECTION
-- Revision 1.29 2005/06/06 11:28:19Z slam
-- Added LastBRN
-- Revision 1.28 2005/05/25 15:50:50Z slam
-- Changed datatype of variable AsAtDate2 from datetime to nvarchar(8)
-- Revision 1.27 2005/05/17 13:19:05Z slam
-- Changed ControlDate and MovementDate
-- Revision 1.26 2005/05/17 12:20:23Z slam
-- Added convert function around LossDate check
-- Revision 1.25 2005/05/12 15:12:47Z slam
-- Encrypted code
-- Revision 1.24 2005/05/10 14:47:34Z slam
-- Added Module parameter and also AsAtDate derivation
-- Revision 1.23 2005/05/10 09:04:10Z slam
-- Added LossDate change check
-- Revision 1.22 2005/05/09 10:15:10Z slam
-- Convert CompanyCode from INT to NVARCHAR
-- Revision 1.21 2005/05/05 14:25:01Z slam
-- Added Accounting Currency
-- Revision 1.20 2005/05/04 09:47:47Z slam
-- Changed movementtype from COR to MOVT when a new financial movement occurs on claim
-- Revision 1.19 2005/05/03 16:46:50Z slam
-- Added InceptionDate
-- Revision 1.18 2005/04/29 10:50:32Z slam
-- Removed non spec'd code changes check and added GLLobCode check
-- Revision 1.17 2005/04/27 16:46:13Z slam
-- Added GLLobCode
-- Revision 1.16 2005/04/27 14:16:53Z slam
-- Added LOBName
-- Revision 1.15 2005/04/27 11:42:59Z slam
-- Added ReserveTypeGroupId - used to group Reserve Types - ;ookup to mst_ClaimTypes
-- Revision 1.14 2005/04/26 13:24:09Z slam
-- Added EnterpriseName
-- Revision 1.13 2005/04/26 10:27:05Z slam
-- Changed ControlDate from INT to DATETIME
-- Revision 1.12 2005/04/25 13:07:54Z slam
-- Removed code to track ClassCode changes
-- Revision 1.11 2005/04/22 16:14:59Z slam
-- Removed table columns from INSERTS
-- Revision 1.10 2005/04/22 09:04:01Z slam
-- Added OriginalCurrency check to generate contra and correction
-- Revision 1.9 2005/04/21 10:40:54Z slam
-- Added AsAtDate variable and now using function msf_GetOpenMonth
-- Revision 1.8 2005/04/20 16:49:51Z slam
-- Added OriginalCurrency and BRN to mst_NewClaimMovements
-- Revision 1.7 2005/04/20 10:40:17Z slam
-- Added ReserveType to ClaimDescription for processlog entry
-- Revision 1.6 2005/04/18 16:20:27Z slam
-- Added financial columns Current... for Richard Strachan view.
-- Revision 1.5 2005/04/18 15:19:57Z slam
-- Removed Paids
-- Revision 1.4 2005/04/17 16:34:20Z slam
-- Separated out Paids, Outstandings, ACR and IBNR
-- Revision 1.3 2005/04/15 08:28:48Z slam
-- Added Latest Position logic, so that the current position(movement) can be identified from the post table.
-- Revision 1.2 2005/04/14 14:37:43Z slam
-- To produce one line for CONTRA and one line for CORRECTION
-- Revision 1.1 2005/04/13 15:00:46Z slam
-- Initial revision
--
--##########################################################################



set nocount on




declare @ProcedureName nvarchar(255),@LogDetail int, @RcdCnt int,@dttm datetime, @seqnum int
set @ProcedureName = object_name(@@procid)


set @LogDetail = 1


set @seqnum = 0


exec msp_ProcessLog 'START', @ProcedureName, @BRN, @Client


declare @AsAtDate2 nvarchar(8),
@LastBrn nvarchar(50),
@NewMovt int


set @AsAtDate2 = (select convert(nvarchar(8),dateadd(d, 1, AsAtDate),112) from mst_ImportControl where Type = @Client and Module = @Module)
set @LastBrn = (select LastBrn from mst_ImportControl where Type = @Client and Module = @Module)
--select * from mst_ImportControl
declare
@IRISUniqueIdImp int,
@CompanyCodeImp nvarchar (10),
@PolicyNumberImp int,
@PolicySequenceImp int,
@PolicyYearImp int,
@PolicyDeclarationNumberImp int,
@PolicyEndorsementNumberImp int,
@ClaimNumberImp int,
@ConvertedClaimNumberImp nvarchar (25),
@PolicyReferenceImp nvarchar (50),
@ClaimReferenceImp nvarchar (60),
@ClaimDescriptionImp nvarchar (150),
@InceptionDateImp datetime,
@ControlDateImp datetime, --also known as movementdate
@ControlDateIRISImp datetime,
@EntryDateImp datetime,
@LossDateImp datetime,
@LossYearImp int,
@LossAdviceDateImp datetime,
@ExchangeRateValueDateImp datetime,
@ExchangeRateYearImp nvarchar (4),
@ExchangeRateMonthImp nvarchar (2),
@GlobalSegmentImp nvarchar (1),
@ProducingOfficeImp nvarchar (10),
@WritingCompanyImp nvarchar (10),
@UnderwriterImp nvarchar (3),
@BrokerImp nvarchar (5),
@UnderwriterAnalysisCodeImp nvarchar (3),
@GLLobCodeImp nvarchar (6),
@PolicyStatusImp nvarchar (2),
@PolicyTypeImp nvarchar (20),
@PolicyType2Imp nvarchar (20),
@ClassCodeImp nvarchar (6),
@InsuredImp nvarchar (45),
@RiskTerritoryImp nvarchar (20),
@DirectAssumedImp nvarchar (1),
@ReserveTypeImp nvarchar (1),
@ReserveTypeGroupIdImp int,
@AccountingCurrencyImp nvarchar (3),
@OriginalCurrencyImp nvarchar (3),
@OriginalBalanceImp float,
@OriginalMovtAmountImp float,
@ExchangeRateImp float,
@BaseBalanceImp float,
@BaseMovtAmountImp float,
@CurrentExchangeRateImp float,
@CurrentBaseBalanceImp float,
@CurrentBaseMovtAmountImp float,


@FunctionalCurrencyImp nvarchar (3),
@FunctionalExchangeRateImp float,
@FunctionalBalanceImp float,
@FunctionalMovtAmountImp float,
@CurrentFunctionalExchangeRateImp float,
@CurrentFunctionalBalanceImp float,
@CurrentFunctionalMovtAmountImp float,


@SumOrigOutstandingsMovt float,
@SumOrigACRMovt float,
@SumOrigIBNRMovt float,
@SumBaseOutstandingsMovt float,
@SumBaseACRMovt float,
@SumBaseIBNRMovt float,
@SumCurrentBaseOutstandingsMovt float,
@SumCurrentBaseACRMovt float,
@SumCurrentBaseIBNRMovt float,


@SumFunctionalOutstandingsMovt float,
@SumFunctionalACRMovt float,
@SumFunctionalIBNRMovt float,
@SumCurrentFunctionalOutstandingsMovt float,
@SumCurrentFunctionalACRMovt float,
@SumCurrentFunctionalIBNRMovt float,


@ClaimChangeDescription nvarchar(255),
@Phase nvarchar(50),
@AnalysisToUpdate int,


--POST
@IRISUniqueId int,
@CompanyCode nvarchar (10),
@PolicyNumber int,
@PolicySequence int,
@PolicyYear int,
@PolicyDeclarationNumber int,
@PolicyEndorsementNumber int,
@ClaimNumber int,
@ConvertedClaimNumber nvarchar (25),
@PolicyReference nvarchar (50),
@ClaimReference nvarchar (60),
@ClaimDescription nvarchar (150),
@InceptionDate datetime,
@ControlDateIRIS datetime,
@EntryDate datetime,
@LossDate datetime,
@LossYear int,
@LossAdviceDate datetime,
@ExchangeRateValueDate datetime,
@ExchangeRateYear nvarchar (4),
@ExchangeRateMonth nvarchar (2),
@GlobalSegment nvarchar (1),
@ProducingOffice nvarchar (10),
@WritingCompany nvarchar (3),
@Underwriter nvarchar (3),
@Broker nvarchar (5),
@UnderwriterAnalysisCode nvarchar (3),
@GLLobCode nvarchar (6),
@PolicyStatus nvarchar (2),
@PolicyType nvarchar (20),
@PolicyType2 nvarchar (20),
@ClassCode nvarchar (6),
@LOBName nvarchar (50),
@Insured nvarchar (45),
@RiskTerritory nvarchar (20),
@DirectAssumed nvarchar (1),
@ReserveType nvarchar (1),
@ReserveTypeGroupId int,
@AccountingCurrency nvarchar (3),
@OriginalCurrency nvarchar (3),
@OriginalBalance float,
@OriginalMovtAmount float,
@OrigOutstandingsMovt float,
@OrigACRMovt float,
@OrigIBNRMovt float,


@ExchangeRate float,
@BaseBalance float,
@BaseMovtAmount float,
@BaseOutstandingsMovt float,
@BaseACRMovt float,
@BaseIBNRMovt float,


@CurrentExchangeRate float,
@CurrentBaseBalance float,
@CurrentBaseOutstandingsMovt float,
@CurrentBaseACRMovt float,
@CurrentBaseIBNRMovt float,


@FunctionalCurrency nvarchar (3),
@FunctionalExchangeRate float,
@FunctionalBalance float,
@FunctionalMovtAmount float,
@FunctionalOutstandingsMovt float,
@FunctionalACRMovt float,
@FunctionalIBNRMovt float,
@CurrentFunctionalExchangeRate float,
@CurrentFunctionalBalance float,
@CurrentFunctionalOutstandingsMovt float,
@CurrentFunctionalACRMovt float,
@CurrentFunctionalIBNRMovt float


/** This table holds the latest position by Original Currency, Reserve type and Accounting Currency for each claim **/
/** To get the correct order of the movements from IRIS need to order first by ControlDate then KTKTID **/
/** This table is checked again POST table for any new movements or change code **/


truncate table mst_NewClaimMovements


set @dttm = getdate()


insert into
dbo.mst_NewClaimMovements
select
max(c1.IRISUniqueId) as IRISUniqueId,
c1.ReserveType,
c1.ClaimReference,
c1.OriginalCurrency,
c1.AccountingCurrency,
c1.BRN
from
dbo.mst_ClaimMovementsImp c1
where
c1.ControlDateIRIS = (select
max(c2.ControldateIRIS)
from
dbo.mst_ClaimMovementsImp c2
where
c2.ReserveType = c1.ReserveType and
c2.ClaimReference = c1.ClaimReference and
c2.OriginalCurrency = c1.OriginalCurrency and
c2.AccountingCurrency = c1.AccountingCurrency)
group by
c1.ReserveType,
c1.ClaimReference,
c1.OriginalCurrency,
c1.AccountingCurrency,
c1.BRN


set @RcdCnt = @@ROWCOUNT
set @seqnum= @seqnum + 1

if @LogDetail =1
begin
insert into mst_LogDetails(sp_name, Dttm,dttm2, TableName,SeqNum, RcdCnt)
select OBJECT_NAME(@@PROCID), @dttm,getdate(), 'mst_NewClaimMovements',@seqnum,@RcdCnt
end



truncate table mst_OldClaimMovements


set @dttm = getdate()


insert into
dbo.mst_OldClaimMovements
select
max(c1.ClaimMovtId) as ClaimMovtId,
-- c1.IRISUniqueId,
c1.ReserveType,
c1.ClaimReference,
c1.OriginalCurrency,
c1.AccountingCurrency
from
dbo.mst_ClaimMovements c1
group by
-- c1.IRISUniqueId,
c1.ReserveType,
c1.ClaimReference,
c1.OriginalCurrency,
c1.AccountingCurrency


set @RcdCnt = @@ROWCOUNT
set @seqnum= @seqnum + 1

if @LogDetail =1
begin
insert into mst_LogDetails(sp_name, Dttm,dttm2, TableName,SeqNum, RcdCnt)
select OBJECT_NAME(@@PROCID), @dttm,getdate(), 'mst_OldClaimMovements',@seqnum,@RcdCnt
end


declare ClaimMovements cursor
for
SELECT
C.IRISUNIQUEID,
CONVERT(NVARCHAR(10),C.COMPANYCODE) AS COMPANYCODE,
C.POLICYNUMBER,
C.POLICYSEQUENCE,
C.POLICYYEAR,
C.POLICYDECLARATIONNUMBER,
C.POLICYENDORSEMENTNUMBER,
C.CLAIMNUMBER,
C.CONVERTEDCLAIMNUMBER,
C.POLICYREFERENCE,
C.CLAIMREFERENCE,
C.CLAIMDESCRIPTION,
C.INCEPTIONDATE,
C.CONTROLDATEIRIS,
C.ENTRYDATE,
C.LOSSDATE,
C.LOSSYEAR,
C.LOSSADVICEDATE,
C.EXCHANGERATEVALUEDATE,
C.EXCHANGERATEYEAR,
C.EXCHANGERATEMONTH,
C.GLOBALSEGMENT,
C.PRODUCINGOFFICE,
C.WRITINGCOMPANY,
C.UNDERWRITER,
C.BROKER,
C.UNDERWRITERANALYSISCODE,
C.GLLOBCODE,
C.POLICYSTATUS,
C.POLICYTYPE,
C.POLICYTYPE2,
C.CLASSCODE,
C.INSURED,
C.RISKTERRITORY,
C.DIRECTASSUMED,
C.RESERVETYPE,
C.ACCOUNTINGCURRENCY,
C.ORIGINALCURRENCY,
C.ORIGINALBALANCE,
C.ORIGINALMOVTAMOUNT,
C.EXCHANGERATE,
C.BASEBALANCE,
C.BASEMOVTAMOUNT,
C.CURRENTEXCHANGERATE,
C.CURRENTBASEBALANCE,
C.CURRENTBASEMOVTAMOUNT,
C.FUNCTIONALCURRENCY,
C.FUNCTIONALEXCHANGERATE,
C.FUNCTIONALBALANCE,
C.FUNCTIONALMOVTAMOUNT,
C.CURRENTFUNCTIONALEXCHANGERATE,
C.CURRENTFUNCTIONALBALANCE,
C.CURRENTFUNCTIONALMOVTAMOUNT,
T.GROUPID
FROM
dbo.MST_CLAIMMOVEMENTSIMP C INNER JOIN
dbo.MST_NEWCLAIMMOVEMENTS N ON
C.IRISUNIQUEID = N.IRISUNIQUEID AND
C.RESERVETYPE = N.RESERVETYPE AND
C.CLAIMREFERENCE = N.CLAIMREFERENCE AND
C.ORIGINALCURRENCY = N.ORIGINALCURRENCY AND
C.ACCOUNTINGCURRENCY = N.ACCOUNTINGCURRENCY INNER JOIN
dbo.MST_CLAIMTYPES T ON C.RESERVETYPE = T.TYPECODE


ORDER BY
C.POLICYREFERENCE,
C.CLAIMREFERENCE,
C.ORIGINALCURRENCY,
C.ACCOUNTINGCURRENCY,
C.RESERVETYPE,
C.CONTROLDATEIRIS,
C.IRISUNIQUEID
for read only



set @dttm = getdate()
set @RcdCnt = 0



open
ClaimMovements
fetch
ClaimMovements
into
@IRISUniqueIdImp,
@CompanyCodeImp,
@PolicyNumberImp,
@PolicySequenceImp,
@PolicyYearImp,
@PolicyDeclarationNumberImp,
@PolicyEndorsementNumberImp,
@ClaimNumberImp,
@ConvertedClaimNumberImp,
@PolicyReferenceImp,
@ClaimReferenceImp,
@ClaimDescriptionImp,
@InceptionDateImp,
@ControlDateIRISImp,
@EntryDateImp,
@LossDateImp,
@LossYearImp,
@LossAdviceDateImp,
@ExchangeRateValueDateImp,
@ExchangeRateYearImp,
@ExchangeRateMonthImp,
@GlobalSegmentImp,
@ProducingOfficeImp,
@WritingCompanyImp,
@UnderwriterImp,
@BrokerImp,
@UnderwriterAnalysisCodeImp,
@GLLobCodeImp,
@PolicyStatusImp,
@PolicyTypeImp,
@PolicyType2Imp,
@ClassCodeImp,
@InsuredImp,
@RiskTerritoryImp,
@DirectAssumedImp,
@ReserveTypeImp,
@AccountingCurrencyImp,
@OriginalCurrencyImp,
@OriginalBalanceImp,
@OriginalMovtAmountImp,
@ExchangeRateImp,
@BaseBalanceImp,
@BaseMovtAmountImp,
@CurrentExchangeRateImp,
@CurrentBaseBalanceImp,
@CurrentBaseMovtAmountImp,
@FunctionalCurrencyImp,
@FunctionalExchangeRateImp,
@FunctionalBalanceImp,
@FunctionalMovtAmountImp,
@CurrentFunctionalExchangeRateImp,
@CurrentFunctionalBalanceImp,
@CurrentFunctionalMovtAmountImp,
@ReserveTypeGroupIdImp


while (@@fetch_status = 0)
begin


select
@SumOrigOutstandingsMovt = isnull(sum(OrigOutstandingsMovt),0),
@SumOrigACRMovt = isnull(sum(OrigACRMovt),0),
@SumOrigIBNRMovt = isnull(sum(OrigIBNRMovt),0),
@SumBaseOutstandingsMovt = isnull(sum(BaseOutstandingsMovt),0),
@SumBaseACRMovt = isnull(sum(BaseACRMovt),0),
@SumBaseIBNRMovt = isnull(sum(BaseIBNRMovt),0),
@SumCurrentBaseOutstandingsMovt = isnull(sum(CurrentBaseOutstandingsMovt),0),
@SumCurrentBaseACRMovt = isnull(sum(CurrentBaseACRMovt),0),
@SumCurrentBaseIBNRMovt = isnull(sum(CurrentBaseIBNRMovt),0),
@SumFunctionalOutstandingsMovt = isnull(sum(FunctionalOutstandingsMovt),0),
@SumFunctionalACRMovt = isnull(sum(FunctionalACRMovt),0),
@SumFunctionalIBNRMovt = isnull(sum(FunctionalIBNRMovt),0),
@SumCurrentFunctionalOutstandingsMovt = isnull(sum(CurrentFunctionalOutstandingsMovt),0),
@SumCurrentFunctionalACRMovt = isnull(sum(CurrentFunctionalACRMovt),0),
@SumCurrentFunctionalIBNRMovt = isnull(sum(CurrentFunctionalIBNRMovt),0)
from
dbo.mst_ClaimMovements C
where
c.ReserveType = @ReserveTypeImp and
c.ClaimReference = @ClaimReferenceImp and
c.OriginalCurrency = @OriginalCurrencyImp and
c.AccountingCurrency = @AccountingCurrencyImp


set @ControlDateImp = (select dbo.msf_GetOpenMonth (@PolicyType2Imp, @CompanyCodeImp, @LastBRN, @AsAtDate2))
set @NewMovt = 0


-- check if transaction record exists in mst_ClaimMovements table, if not it is a new movement
if not exists (select
NULL
from
dbo.mst_ClaimMovements cm
where
cm.IRISUniqueId = @IRISUniqueIdImp and
cm.ReserveType = @ReserveTypeImp and
cm.ClaimReference = @ClaimReferenceImp and
cm.OriginalCurrency = @OriginalCurrencyImp and
cm.AccountingCurrency = @AccountingCurrencyImp)
begin
-- new movement detected and will be added, so make latest position in mst_ClaimMovements not the latest
update
dbo.mst_ClaimMovements
set
LatestPosition = 0
where
LatestPosition = 1 and
ReserveType = @ReserveTypeImp and
ClaimReference = @ClaimReferenceImp and
OriginalCurrency = @OriginalCurrencyImp and
AccountingCurrency = @AccountingCurrencyImp


-- movt amount is (balance in import table) - (sum of movts in mst_ClaimMovements)
insert into
mst_ClaimMovements
select
@Client, @IRISUniqueIdImp, @CompanyCodeImp, @PolicyNumberImp, @PolicySequenceImp, @PolicyYearImp, @PolicyDeclarationNumberImp,
@PolicyEndorsementNumberImp, @ClaimNumberImp, @ConvertedClaimNumberImp, @PolicyReferenceImp, @ClaimReferenceImp, @ClaimDescriptionImp,
@InceptionDateImp, @ControlDateImp, @ControlDateIRISImp, @EntryDateImp, @LossDateImp, @LossYearImp, @LossAdviceDateImp,
@ExchangeRateValueDateImp, @ExchangeRateYearImp, @ExchangeRateMonthImp, @GlobalSegmentImp, @ProducingOfficeImp, @WritingCompanyImp,
@UnderwriterImp, @BrokerImp, @UnderwriterAnalysisCodeImp, @GLLobCodeImp, @PolicyStatusImp, @PolicyTypeImp, @PolicyType2Imp, @ClassCodeImp,
'', --LOBName
@InsuredImp, @RiskTerritoryImp, @DirectAssumedImp, @ReserveTypeImp, @ReserveTypeGroupIdImp, @AccountingCurrencyImp,@OriginalCurrencyImp,
@OriginalBalanceImp,
case when @ReserveTypeGroupIdImp = 1 then @OriginalBalanceImp - @SumOrigOutstandingsMovt else 0 end, --OrigOutstandingsMovt
case when @ReserveTypeGroupIdImp = 2 then @OriginalBalanceImp - @SumOrigACRMovt else 0 end, --OrigACRMovt
case when @ReserveTypeGroupIdImp = 3 then @OriginalBalanceImp - @SumOrigIBNRMovt else 0 end, --OrigIBNRMovt
@ExchangeRateImp,
@BaseBalanceImp,
case when @ReserveTypeGroupIdImp = 1 then @BaseBalanceImp - @SumBaseOutstandingsMovt else 0 end, --BaseOutstandingsMovt
case when @ReserveTypeGroupIdImp = 2 then @BaseBalanceImp - @SumBaseACRMovt else 0 end, --BaseACRMovt
case when @ReserveTypeGroupIdImp = 3 then @BaseBalanceImp - @SumBaseIBNRMovt else 0 end, --BaseIBNRMovt
@BRN,
'MOVT', --new movement stamped with MOVT meaning a geniune financial movement to claim
1, --flag as latest position
@CurrentExchangeRateImp,
@CurrentBaseBalanceImp,
case when @ReserveTypeGroupIdImp = 1 then @CurrentBaseBalanceImp - @SumCurrentBaseOutstandingsMovt else 0 end, --CurrentBaseOutstandingsMovt
case when @ReserveTypeGroupIdImp = 2 then @CurrentBaseBalanceImp - @SumCurrentBaseACRMovt else 0 end, --CurrentBaseACRMovt
case when @ReserveTypeGroupIdImp = 3 then @CurrentBaseBalanceImp - @SumCurrentBaseIBNRMovt else 0 end, --CurrentBaseIBNRMovt
@FunctionalCurrencyImp,
@FunctionalExchangeRateImp,
@FunctionalBalanceImp,
case when @ReserveTypeGroupIdImp = 1 then @FunctionalBalanceImp - @SumFunctionalOutstandingsMovt else 0 end, --FunctionalOutstandingsMovt
case when @ReserveTypeGroupIdImp = 2 then @FunctionalBalanceImp - @SumFunctionalACRMovt else 0 end, --FunctionalACRMovt
case when @ReserveTypeGroupIdImp = 3 then @FunctionalBalanceImp - @SumFunctionalIBNRMovt else 0 end, --FunctionalIBNRMovt
@CurrentFunctionalExchangeRateImp,
@CurrentFunctionalBalanceImp,
case when @ReserveTypeGroupIdImp = 1 then @CurrentFunctionalBalanceImp - @SumCurrentFunctionalOutstandingsMovt else 0 end, --CurrentFunctionalOutstandingsMovt
case when @ReserveTypeGroupIdImp = 2 then @CurrentFunctionalBalanceImp - @SumCurrentFunctionalACRMovt else 0 end, --CurrentFunctionalACRMovt
case when @ReserveTypeGroupIdImp = 3 then @CurrentFunctionalBalanceImp - @SumCurrentFunctionalIBNRMovt else 0 end --CurrentFunctionalIBNRMovt


set @NewMovt = 1
end --Not Exists


if exists (select
NULL
from
dbo.mst_OldClaimMovements cm
where
cm.ReserveType = @ReserveTypeImp and
cm.ClaimReference = @ClaimReferenceImp and
cm.OriginalCurrency = @OriginalCurrencyImp and
cm.AccountingCurrency = @AccountingCurrencyImp)
begin
select
@IRISUniqueId = c.IRISUniqueId,
@CompanyCode = CompanyCode,
@PolicyNumber = PolicyNumber,
@PolicySequence = PolicySequence,
@PolicyYear = PolicyYear,
@PolicyDeclarationNumber = PolicyDeclarationNumber,
@PolicyEndorsementNumber = PolicyEndorsementNumber,
@ClaimNumber = ClaimNumber,
@ConvertedClaimNumber = ConvertedClaimNumber,
@PolicyReference = PolicyReference,
@ClaimReference = c.ClaimReference,
@ClaimDescription = ClaimDescription,
@InceptionDate = InceptionDate,
@ControlDateIRIS = ControlDate,
@EntryDate = EntryDate,
@LossDate = LossDate,
@LossYear = LossYear,
@LossAdviceDate = LossAdviceDate,
@ExchangeRateValueDate = ExchangeRateValueDate,
@ExchangeRateYear = ExchangeRateYear,
@ExchangeRateMonth = ExchangeRateMonth,
@GlobalSegment = GlobalSegment,
@ProducingOffice = ProducingOffice,
@WritingCompany = WritingCompany,
@Underwriter = Underwriter,
@Broker = Broker,
@UnderwriterAnalysisCode = UnderwriterAnalysisCode,
@GLLobCode = GLLobCode,
@PolicyStatus = PolicyStatus,
@PolicyType = PolicyType,
@PolicyType2 = PolicyType2,
@ClassCode = ClassCode,
@LOBName = LOBName,
@Insured = Insured,
@RiskTerritory = RiskTerritory,
@DirectAssumed = DirectAssumed,
@ReserveType = c.ReserveType,
@ReserveTypeGroupId = ReserveTypeGroupId,
@AccountingCurrency = c.AccountingCurrency,
@OriginalCurrency = c.OriginalCurrency,
@OriginalBalance = OriginalBalance,
@OrigOutstandingsMovt = OrigOutstandingsMovt,
@OrigACRMovt = OrigACRMovt,
@OrigIBNRMovt = OrigIBNRMovt,
@ExchangeRate = ExchangeRate,
@BaseBalance = BaseBalance,
@BaseOutstandingsMovt = BaseOutstandingsMovt,
@BaseACRMovt = BaseACRMovt,
@BaseIBNRMovt = BaseIBNRMovt,
@CurrentExchangeRate = CurrentExchangeRate,
@CurrentBaseBalance = CurrentBaseBalance,
@CurrentBaseOutstandingsMovt = CurrentBaseOutstandingsMovt,
@CurrentBaseACRMovt = CurrentBaseACRMovt,
@CurrentBaseIBNRMovt = CurrentBaseIBNRMovt,
@FunctionalCurrency = c.FunctionalCurrency,
@FunctionalExchangeRate = FunctionalExchangeRate,
@FunctionalBalance = FunctionalBalance,
@FunctionalOutstandingsMovt = FunctionalOutstandingsMovt,
@FunctionalACRMovt = FunctionalACRMovt,
@FunctionalIBNRMovt = FunctionalIBNRMovt,
@CurrentFunctionalExchangeRate = CurrentFunctionalExchangeRate,
@CurrentFunctionalBalance = CurrentFunctionalBalance,
@CurrentFunctionalOutstandingsMovt = CurrentFunctionalOutstandingsMovt,
@CurrentFunctionalACRMovt = CurrentFunctionalACRMovt,
@CurrentFunctionalIBNRMovt = CurrentFunctionalIBNRMovt
from
dbo.mst_ClaimMovements c inner join
dbo.mst_OldClaimMovements n on
c.ClaimMovtId = n.ClaimMovtId and
-- c.IRISUniqueId = n.IRISUniqueId and
c.ReserveType = n.ReserveType and
c.ClaimReference = n.ClaimReference and
c.OriginalCurrency = n.OriginalCurrency and
c.AccountingCurrency = n.AccountingCurrency inner join
dbo.mst_ClaimTypes t on c.ReserveType = t.TypeCode
where
c.ReserveType = @ReserveTypeImp and
c.ClaimReference = @ClaimReferenceImp and
c.OriginalCurrency = @OriginalCurrencyImp and
c.AccountingCurrency = @AccountingCurrencyImp


set @AnalysisToUpdate = 0


if @LossDate != @LossDateImp
begin
set @AnalysisToUpdate = @AnalysisToUpdate + 1
set @Phase = 'LOSS DATE CHANGE DETECTED'
set @ClaimChangeDescription = 'Claim: ' + @ClaimReferenceImp + ', ReserveType: '+ @ReserveTypeImp + ', old value: ' +
convert(nvarchar(2),datepart(dd,@LossDate)) + '/' +
convert(nvarchar(2),datepart(mm,@LossDate)) + '/' +
convert(nvarchar(4),datepart(yy,@LossDate))
+ ', new value: ' +
convert(nvarchar(2),datepart(dd,@LossDateImp)) + '/' +
convert(nvarchar(2),datepart(mm,@LossDateImp)) + '/' +
convert(nvarchar(4),datepart(yy,@LossDateImp))
exec msp_ProcessLog @Phase, @ClaimChangeDescription, @BRN, @Client
end


if @InceptionDate != @InceptionDateImp
begin
set @AnalysisToUpdate = @AnalysisToUpdate + 1
set @Phase = 'INCEPTION DATE CHANGE DETECTED'
set @ClaimChangeDescription = 'Claim: ' + @ClaimReferenceImp + ', ReserveType: '+ @ReserveTypeImp + ', old value: ' +
convert(nvarchar(2),datepart(dd,@InceptionDate)) + '/' +
convert(nvarchar(2),datepart(mm,@InceptionDate)) + '/' +
convert(nvarchar(4),datepart(yy,@InceptionDate))
+ ', new value: ' +
convert(nvarchar(2),datepart(dd,@InceptionDateImp)) + '/' +
convert(nvarchar(2),datepart(mm,@InceptionDateImp)) + '/' +
convert(nvarchar(4),datepart(yy,@InceptionDateImp))
exec msp_ProcessLog @Phase, @ClaimChangeDescription, @BRN, @Client
end


if @OriginalCurrency != @OriginalCurrencyImp
begin
set @AnalysisToUpdate = @AnalysisToUpdate + 1
set @Phase = 'ORIGINAL CURRENCY CHANGE DETECTED'
set @ClaimChangeDescription = 'Claim: ' + @ClaimReferenceImp + ', ReserveType: '+ @ReserveTypeImp + ', old value: ' + @OriginalCurrency + ', new value: ' + @OriginalCurrencyImp
exec msp_ProcessLog @Phase, @ClaimChangeDescription, @BRN, @Client
end


if @FunctionalCurrency != @FunctionalCurrencyImp
begin
set @AnalysisToUpdate = @AnalysisToUpdate + 1
set @Phase = 'FUNCTIONAL CURRENCY CHANGE DETECTED'
set @ClaimChangeDescription = 'Claim: ' + @ClaimReferenceImp + ', ReserveType: '+ @ReserveTypeImp + ', old value: ' + @FunctionalCurrency + ', new value: ' + @FunctionalCurrencyImp
exec msp_ProcessLog @Phase, @ClaimChangeDescription, @BRN, @Client
end


if @DirectAssumed != @DirectAssumedImp
begin
set @AnalysisToUpdate = @AnalysisToUpdate + 1
set @Phase = 'DIRECT\ASSUMED INDICATOR CHANGE DETECTED'
set @ClaimChangeDescription = 'Claim: ' + @ClaimReferenceImp + ', ReserveType: '+ @ReserveTypeImp + ', old value: ' + @DirectAssumed + ', new value: ' + @DirectAssumedImp
exec msp_ProcessLog @Phase, @ClaimChangeDescription, @BRN, @Client
end


if @GlobalSegment != @GlobalSegmentImp
begin
set @AnalysisToUpdate = @AnalysisToUpdate + 1
set @Phase = 'GLOBAL SEGMENT CHANGE DETECTED'
set @ClaimChangeDescription = 'Claim: ' + @ClaimReferenceImp + ', ReserveType: '+ @ReserveTypeImp + ', old value: ' + @GlobalSegment + ', new value: ' + @GlobalSegmentImp
exec msp_ProcessLog @Phase, @ClaimChangeDescription, @BRN, @Client
end


if @WritingCompany != @WritingCompanyImp
begin
set @AnalysisToUpdate = @AnalysisToUpdate + 1
set @Phase = 'WRITING COMPANY CHANGE DETECTED'
set @ClaimChangeDescription = 'Claim: ' + @ClaimReferenceImp + ', ReserveType: '+ @ReserveTypeImp + ', old value: ' + @WritingCompany + ', new value: ' + @WritingCompanyImp
exec msp_ProcessLog @Phase, @ClaimChangeDescription, @BRN, @Client
end


if @Broker != @BrokerImp
begin
set @AnalysisToUpdate = @AnalysisToUpdate + 1
set @Phase = 'BROKER CHANGE DETECTED'
set @ClaimChangeDescription = 'Claim: ' + @ClaimReferenceImp + ', ReserveType: '+ @ReserveTypeImp + ', old value: ' + @Broker + ', new value: ' + @BrokerImp
exec msp_ProcessLog @Phase, @ClaimChangeDescription, @BRN, @Client
end


if @UnderwriterAnalysisCode != @UnderwriterAnalysisCodeImp
begin
set @AnalysisToUpdate = @AnalysisToUpdate + 1
set @Phase = 'UNDERWRITER ANALYSIS CODE CHANGE DETECTED'
set @ClaimChangeDescription = 'Claim: ' + @ClaimReferenceImp + ', ReserveType: '+ @ReserveTypeImp + ', old value: ' + @UnderwriterAnalysisCode + ', new value: ' + @UnderwriterAnalysisCodeImp
exec msp_ProcessLog @Phase, @ClaimChangeDescription, @BRN, @Client
end


if @GLLobCode != @GLLobCodeImp
begin
set @AnalysisToUpdate = @AnalysisToUpdate + 1
set @Phase = 'GL LOB CODE CHANGE DETECTED'
set @ClaimChangeDescription = 'Claim: ' + @ClaimReferenceImp + ', ReserveType: '+ @ReserveTypeImp + ', old value: ' + @GLLobCode + ', new value: ' + @GLLobCodeImp
exec msp_ProcessLog @Phase, @ClaimChangeDescription, @BRN, @Client
end


if @RiskTerritory != @RiskTerritoryImp
begin
set @AnalysisToUpdate = @AnalysisToUpdate + 1
set @Phase = 'RISK TERRITORY CHANGE DETECTED'
set @ClaimChangeDescription = 'Claim: ' + @ClaimReferenceImp + ', ReserveType: '+ @ReserveTypeImp + ', old value: ' + @RiskTerritory + ', new value: ' + @RiskTerritoryImp
exec msp_ProcessLog @Phase, @ClaimChangeDescription, @BRN, @Client
end


if @PolicyType2 != @PolicyType2Imp
begin
set @AnalysisToUpdate = @AnalysisToUpdate + 1
set @Phase = 'POLICY TYPE 2 CHANGE DETECTED'
set @ClaimChangeDescription = 'Claim: ' + @ClaimReferenceImp + ', ReserveType: '+ @ReserveTypeImp + ', old value: ' + convert(nvarchar(50),@PolicyType2) + ', new value: ' + convert(nvarchar(50),@PolicyType2Imp)
exec msp_ProcessLog @Phase, @ClaimChangeDescription, @BRN, @Client
end


if @ClassCode != @ClassCodeImp
begin
set @AnalysisToUpdate = @AnalysisToUpdate + 1
set @Phase = 'CLASS CODE CHANGE DETECTED'
set @ClaimChangeDescription = 'Claim: ' + @ClaimReferenceImp + ', ReserveType: '+ @ReserveTypeImp + ', old value: ' + @ClassCode + ', new value: ' + @ClassCodeImp
exec msp_ProcessLog @Phase, @ClaimChangeDescription, @BRN, @Client
end


-- if change in code detected, create movement
if @AnalysisToUpdate > 0
begin
-- create record to CONTRA the latest position ie. negate sum of previous movements
insert into
dbo.mst_ClaimMovements
select
@Client,@IRISUniqueId,@CompanyCode, @PolicyNumber, @PolicySequence, @PolicyYear, @PolicyDeclarationNumber, @PolicyEndorsementNumber,
@ClaimNumber, @ConvertedClaimNumber, @PolicyReference, @ClaimReference, @ClaimDescription,
@InceptionDate, @ControlDateImp, @ControlDateIRIS, @EntryDate, @LossDate, @LossYear, @LossAdviceDate, @ExchangeRateValueDate, @ExchangeRateYear,
@ExchangeRateMonth, @GlobalSegment, @ProducingOffice, @WritingCompany, @Underwriter, @Broker, @UnderwriterAnalysisCode, @GLLobCode,
@PolicyStatus, @PolicyType, @PolicyType2, @ClassCode, @LOBName, @Insured, @RiskTerritory, @DirectAssumed, @ReserveType,@ReserveTypeGroupIdImp,
@AccountingCurrency, @OriginalCurrency,
@OriginalBalance * -1,
case when @ReserveTypeGroupIdImp = 1 then @SumOrigOutstandingsMovt * -1 else 0 end, --OrigOutstandingsMovt
case when @ReserveTypeGroupIdImp = 2 then @SumOrigACRMovt * -1 else 0 end, --OrigACRMovt
case when @ReserveTypeGroupIdImp = 3 then @SumOrigIBNRMovt * -1 else 0 end, --OrigIBNRMovt
@ExchangeRate,
@BaseBalance * -1,
case when @ReserveTypeGroupIdImp = 1 then @SumBaseOutstandingsMovt * -1 else 0 end, --BaseOutstandingsMovt
case when @ReserveTypeGroupIdImp = 2 then @SumBaseACRMovt * -1 else 0 end, --BaseACRMovt
case when @ReserveTypeGroupIdImp = 3 then @SumBaseIBNRMovt * -1 else 0 end, --BaseIBNRMovt
@BRN,
'CON',
0,
@CurrentExchangeRate,
@CurrentBaseBalance * -1,
case when @ReserveTypeGroupIdImp = 1 then @SumCurrentBaseOutstandingsMovt * -1 else 0 end, --CurrentBaseOutstandingsMovt
case when @ReserveTypeGroupIdImp = 2 then @SumCurrentBaseACRMovt * -1 else 0 end, --CurrentBaseACRMovt
case when @ReserveTypeGroupIdImp = 3 then @SumCurrentBaseIBNRMovt * -1 else 0 end, --CurrentBaseIBNRMovt
@FunctionalCurrency,
@FunctionalExchangeRate,
@FunctionalBalance * -1,
case when @ReserveTypeGroupIdImp = 1 then @SumFunctionalOutstandingsMovt * -1 else 0 end, --FunctionalOutstandingsMovt
case when @ReserveTypeGroupIdImp = 2 then @SumFunctionalACRMovt * -1 else 0 end, --FunctionalACRMovt
case when @ReserveTypeGroupIdImp = 3 then @SumFunctionalIBNRMovt * -1 else 0 end, --FunctionalIBNRMovt
@CurrentFunctionalExchangeRate,
@CurrentFunctionalBalance,
case when @ReserveTypeGroupIdImp = 1 then @SumCurrentFunctionalOutstandingsMovt * -1 else 0 end, --CurrentFunctionalOutstandingsMovt
case when @ReserveTypeGroupIdImp = 2 then @SumCurrentFunctionalACRMovt * -1 else 0 end, --CurrentFunctionalACRMovt
case when @ReserveTypeGroupIdImp = 3 then @SumCurrentFunctionalIBNRMovt * -1 else 0 end --CurrentFunctionalIBNRMovt


if @NewMovt = 1
begin
set @OriginalBalanceImp = case @ReserveTypeGroupIdImp
when 1 then @SumOrigOutstandingsMovt
when 2 then @SumOrigACRMovt
when 3 then @SumOrigIBNRMovt
end


set @BaseBalanceImp = case @ReserveTypeGroupIdImp
when 1 then @SumBaseOutstandingsMovt
when 2 then @SumBaseACRMovt
when 3 then @SumBaseIBNRMovt
end


set @CurrentBaseBalanceImp = case @ReserveTypeGroupIdImp
when 1 then @SumCurrentBaseOutstandingsMovt
when 2 then @SumCurrentBaseACRMovt
when 3 then @SumCurrentBaseIBNRMovt
end


set @FunctionalBalanceImp = case @ReserveTypeGroupIdImp
when 1 then @SumFunctionalOutstandingsMovt
when 2 then @SumFunctionalACRMovt
when 3 then @SumFunctionalIBNRMovt
end


set @CurrentFunctionalBalanceImp = case @ReserveTypeGroupIdImp
when 1 then @SumCurrentFunctionalOutstandingsMovt
when 2 then @SumCurrentFunctionalACRMovt
when 3 then @SumCurrentFunctionalIBNRMovt
end
end
else
begin
update
dbo.mst_ClaimMovements
set
LatestPosition = 0
where
LatestPosition = 1 and
ReserveType = @ReserveTypeImp and
ClaimReference = @ClaimReferenceImp and
OriginalCurrency = @OriginalCurrencyImp and
AccountingCurrency = @AccountingCurrencyImp
end


-- add CORRECTION record and mark as latest position ie. sum of previous movements with new codes
insert into
dbo.mst_ClaimMovements
select
@Client,@IRISUniqueIdImp,@CompanyCodeImp, @PolicyNumberImp, @PolicySequenceImp, @PolicyYearImp, @PolicyDeclarationNumberImp,
@PolicyEndorsementNumberImp, @ClaimNumberImp, @ConvertedClaimNumberImp, @PolicyReferenceImp, @ClaimReferenceImp, @ClaimDescriptionImp,
@InceptionDateImp, @ControlDateImp, @ControlDateIRISImp, @EntryDateImp, @LossDateImp, @LossYearImp, @LossAdviceDateImp,
@ExchangeRateValueDateImp, @ExchangeRateYearImp, @ExchangeRateMonthImp, @GlobalSegmentImp, @ProducingOfficeImp, @WritingCompanyImp,
@UnderwriterImp, @BrokerImp, @UnderwriterAnalysisCodeImp,@GLLobCodeImp, @PolicyStatusImp, @PolicyTypeImp, @PolicyType2Imp, @ClassCodeImp,
'', --LOBName
@InsuredImp, @RiskTerritoryImp, @DirectAssumedImp, @ReserveTypeImp, @ReserveTypeGroupIdImp,@AccountingCurrencyImp, @OriginalCurrencyImp,
@OriginalBalanceImp,
case when @ReserveTypeGroupIdImp = 1 then @OriginalBalanceImp else 0 end, --OrigOutstandingsMovt
case when @ReserveTypeGroupIdImp = 2 then @OriginalBalanceImp else 0 end, --OrigACRMovt
case when @ReserveTypeGroupIdImp = 3 then @OriginalBalanceImp else 0 end, --OrigIBNRMovt
@ExchangeRateImp,
@BaseBalanceImp,
case when @ReserveTypeGroupIdImp = 1 then @BaseBalanceImp else 0 end, --BaseOutstandingsMovt
case when @ReserveTypeGroupIdImp = 2 then @BaseBalanceImp else 0 end, --BaseACRMovt
case when @ReserveTypeGroupIdImp = 3 then @BaseBalanceImp else 0 end, --BaseIBNRMovt
@BRN,
'COR',
case @NewMovt when 1 then 0 else 1 end,
@CurrentExchangeRateImp,
@CurrentBaseBalanceImp,
case when @ReserveTypeGroupIdImp = 1 then @CurrentBaseBalanceImp else 0 end, --CurrentBaseOutstandingsMovt
case when @ReserveTypeGroupIdImp = 2 then @CurrentBaseBalanceImp else 0 end, --CurrentBaseACRMovt
case when @ReserveTypeGroupIdImp = 3 then @CurrentBaseBalanceImp else 0 end, --CurrentBaseIBNRMovt
@FunctionalCurrencyImp,
@FunctionalExchangeRateImp,
@FunctionalBalanceImp,
case when @ReserveTypeGroupIdImp = 1 then @FunctionalBalanceImp else 0 end, --FunctionalOutstandingsMovt
case when @ReserveTypeGroupIdImp = 2 then @FunctionalBalanceImp else 0 end, --FunctionalACRMovt
case when @ReserveTypeGroupIdImp = 3 then @FunctionalBalanceImp else 0 end, --FunctionalIBNRMovt
@CurrentFunctionalExchangeRateImp,
@CurrentFunctionalBalanceImp,
case when @ReserveTypeGroupIdImp = 1 then @CurrentFunctionalBalanceImp else 0 end, --CurrentFunctionalOutstandingsMovt
case when @ReserveTypeGroupIdImp = 2 then @CurrentFunctionalBalanceImp else 0 end, --CurrentFunctionalACRMovt
case when @ReserveTypeGroupIdImp = 3 then @CurrentFunctionalBalanceImp else 0 end --CurrentFunctionalIBNRMovt
end --if @AnalysisToUpdate > 0, i.e Change in Analysis Code
end


fetch
ClaimMovements
into
@IRISUniqueIdImp,
@CompanyCodeImp,
@PolicyNumberImp,
@PolicySequenceImp,
@PolicyYearImp,
@PolicyDeclarationNumberImp,
@PolicyEndorsementNumberImp,
@ClaimNumberImp,
@ConvertedClaimNumberImp,
@PolicyReferenceImp,
@ClaimReferenceImp,
@ClaimDescriptionImp,
@InceptionDateImp,
@ControlDateIRISImp,
@EntryDateImp,
@LossDateImp,
@LossYearImp,
@LossAdviceDateImp,
@ExchangeRateValueDateImp,
@ExchangeRateYearImp,
@ExchangeRateMonthImp,
@GlobalSegmentImp,
@ProducingOfficeImp,
@WritingCompanyImp,
@UnderwriterImp,
@BrokerImp,
@UnderwriterAnalysisCodeImp,
@GLLobCodeImp,
@PolicyStatusImp,
@PolicyTypeImp,
@PolicyType2Imp,
@ClassCodeImp,
@InsuredImp,
@RiskTerritoryImp,
@DirectAssumedImp,
@ReserveTypeImp,
@AccountingCurrencyImp,
@OriginalCurrencyImp,
@OriginalBalanceImp,
@OriginalMovtAmountImp,
@ExchangeRateImp,
@BaseBalanceImp,
@BaseMovtAmountImp,
@CurrentExchangeRateImp,
@CurrentBaseBalanceImp,
@CurrentBaseMovtAmountImp,
@FunctionalCurrencyImp,
@FunctionalExchangeRateImp,
@FunctionalBalanceImp,
@FunctionalMovtAmountImp,
@CurrentFunctionalExchangeRateImp,
@CurrentFunctionalBalanceImp,
@CurrentFunctionalMovtAmountImp,
@ReserveTypeGroupIdImp


set @RcdCnt = @RcdCnt + @@ROWCOUNT

end


set @seqnum= @seqnum + 1

if @LogDetail =1
begin
insert into dbo.mst_LogDetails(sp_name, Dttm,dttm2, TableName,SeqNum, RcdCnt)
select OBJECT_NAME(@@PROCID), @dttm,getdate(), 'Cursor ClaimMovements',@seqnum,@RcdCnt
end



close ClaimMovements
deallocate ClaimMovements


-- add msp_UpdateImportControl here
--exec msp_UpdateImportControl @Client, @Module, @BRN, @AsAtDate2, 'END'


exec msp_ProcessLog 'END', @ProcedureName, @BRN, @Client


set nocount off

cte
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

· Write an Answer

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.