Я не могу добавить новые объявления внутри хранимой процедуры.SP выполняется без ошибок, но ничего не отображается на веб-странице
USE [uriic2018_traveldev]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[spGetReportProducer_Pager]
@ClientId bigint=null,
@Fromdate nvarchar(max)=null,
@Todate nvarchar(max)=null,
@SortExpression NVARCHAR(MAX),
@SortDirection NVARCHAR(MAX),
@PageIndex INT = 1,
@PageSize INT = 50,
@RecordCount INT OUTPUT,
@ActivePolicy INT OUTPUT,
@CancelledPolicy INT OUTPUT,
@TotalPolicy INT OUTPUT,
@OriginalPremium DECIMAL OUTPUT,
@UpdatedPremium DECIMAL OUTPUT
AS
BEGIN
SET NOCOUNT ON;
SELECT ROW_NUMBER() OVER
(
ORDER BY
CASE WHEN ( @SortExpression = 'PolicyNumber' AND @SortDirection='ASC')
THEN P.PolicyNumber
END ASC,
CASE WHEN ( @SortExpression = 'PolicyNumber' AND @SortDirection='DESC')
THEN P.PolicyNumber
END DESC,
CASE WHEN ( @SortExpression = 'Firstname' AND @SortDirection='ASC')
THEN P.FirstName
END ASC,
CASE WHEN ( @SortExpression = 'Firstname' AND @SortDirection='DESC')
THEN P.FirstName
END DESC,
CASE WHEN ( @SortExpression = 'Middlename' AND @SortDirection='ASC')
THEN P.MiddleName
END ASC,
CASE WHEN ( @SortExpression = 'Middlename' AND @SortDirection='DESC')
THEN P.MiddleName
END DESC,
CASE WHEN ( @SortExpression = 'Lastname' AND @SortDirection='ASC')
THEN P.LastName
END ASC,
CASE WHEN ( @SortExpression = 'Lastname' AND @SortDirection='DESC')
THEN P.LastName
END DESC,
CASE WHEN ( @SortExpression = 'OriginalPremium' AND @SortDirection='ASC')
THEN P.Premium
END ASC,
CASE WHEN ( @SortExpression = 'OriginalPremium' AND @SortDirection='DESC')
THEN P.Premium
END DESC,
CASE WHEN ( @SortExpression = 'UpdatedPremium' AND @SortDirection='ASC')
THEN P.TotalPremium
END ASC,
CASE WHEN ( @SortExpression = 'UpdatedPremium' AND @SortDirection='DESC')
THEN P.TotalPremium
END DESC,
CASE WHEN ( @SortExpression = 'IssuedDate' AND @SortDirection='ASC')
THEN P.IssuedDate
END ASC,
CASE WHEN ( @SortExpression = 'IssuedDate' AND @SortDirection='DESC')
THEN P.IssuedDate
END DESC,
CASE WHEN ( @SortExpression = 'EffectiveDate' AND @SortDirection='ASC')
THEN P.Effectivedate
END ASC,
CASE WHEN ( @SortExpression = 'EffectiveDate' AND @SortDirection='DESC')
THEN P.Effectivedate
END DESC,
CASE WHEN ( @SortExpression = 'ExpiryDate' AND @SortDirection='ASC')
THEN P.ExpiryDate
END ASC,
CASE WHEN ( @SortExpression = 'ExpiryDate' AND @SortDirection='DESC')
THEN P.ExpiryDate
END DESC,
CASE WHEN ( @SortExpression = 'Status' AND @SortDirection='ASC')
THEN P.[Status]
END ASC,
CASE WHEN ( @SortExpression = 'Status' AND @SortDirection='DESC')
THEN P.[Status]
END DESC,
CASE WHEN ( @SortExpression = 'Policy' AND @SortDirection='ASC')
THEN P.Policy
END ASC,
CASE WHEN ( @SortExpression = 'Policy' AND @SortDirection='DESC')
THEN P.Policy
END DESC
) AS RowNumber
,P.PolicyId
,P.PolicyNumber
,P.FirstName
,P.MiddleName
,P.LastName
,P.Premium as OriginalPremium
,P.TotalPremium as UpdatedPremium
,format(P.IssuedDate, 'dd/MM/yyyy') as IssuedDate
,format(P.Effectivedate, 'dd/MM/yyyy') as Effectivedate
,format(P.ExpiryDate, 'dd/MM/yyyy') as ExpiryDate
,P.[Status]
,P.Policy
,C.CompanyName AS ProducerName
INTO #Results
FROM PolicyDetails P
left join Clients C on C.ClientId=p.ClientId
where (@ClientId IS NULL OR P.ClientId=@ClientId)
AND (P.IssuedDate between @Fromdate and @Todate OR (@Fromdate='' OR @Todate=''))
SELECT @RecordCount = COUNT(*)
FROM #Results
SELECT @ActivePolicy = COUNT(*)
FROM #Results WHERE [OriginalPremium] > 0
SELECT @CancelledPolicy = COUNT(*)
FROM #Results WHERE [OriginalPremium] < 0
Set @TotalPolicy = @ActivePolicy+@CancelledPolicy
SELECT @OriginalPremium = SUM(OriginalPremium)
FROM #Results
SELECT @UpdatedPremium = SUM(UpdatedPremium)
FROM #Results
SELECT * FROM #Results
WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
DROP TABLE #Results
END
Вышеуказанный SP работает и показывает результаты, но теперь у меня есть некоторые обновления этого кода, в которых я хочу объявить 2 выхода @TotalActive INT OUTPUT
и @TotalRefund INT OUTPUT
, но при добавлении этих 2 в объявлении SP выполняется без ошибок, но результаты, не отображаемые на веб-странице, будут пустыми.