моей хранимой процедуре не удалось вставить в объявленный тип таблицы, уже есть запрос на вставку, но когда я select * from @AktaFiducia
пуст, может ли кто-нибудь помочь мне определить, что я мог сделать неправильно в запросе ниже?
ALTER PROCEDURE [dbo].[InsertFiducia]
@BatchNo Varchar(30),
@LoginID varchar(50),
@Message varchar(1000) output
AS
BEGIN
BEGIN TRY
BEGIN TRAN AKTAFiducia
declare @AktaFiducia table
(
ID int IDENTITY PRIMARY KEY,
BranchID varchar(3),
ApplicationID varchar(20),
SeqNo varchar(3),
AktaNo varchar(50),
AktaDate date,
CertificateNo varchar(50),
CertificateDate date,
InvoiceNo varchar(50),
InvoiceDate date,
InvoiceNote varchar(200),
FiduciaFee numeric(17,2),
BusinessDate Date,
ReceivedBy varchar(50),
NotaryID varchar(20),
AgreementNo varchar(20),
ServiceFee numeric(17,2),
FiduciaSeqNo int
)
insert into @AktaFiducia
select
fd.BranchID,
fd.ApplicationID,
fd.AssetSeqNo,
ufr.AktaNo,
ufr.AktaDate,
fd.CertificateNo,
fd.CertificateDate,
ufr.InvoiceNumber,
ufr.InvoiceDate,
fd.InvoiceNotes,
NotaryCharge.AktaFee,
GETDATE(),
'Upload-System',
fd.NotaryId,
ufr.NoKontrak,
NotaryCharge.ServiceFee,
FiduciaSeqNo
from UploadFidusiaAktaRecieve ufr with (nolock)
inner join dbo.Agreement agr with (nolock) on agr.AgreementNo = ufr.NoKontrak
inner join dbo.Fiducia fd with (nolock) on fd.BranchID = agr.BranchID and fd.ApplicationID = agr.ApplicationID
and fd.AssetSeqNo = ufr.AssetSeqNo and ISNULL(fd.CustomerID,'') = ISNULL(ufr.CustomerID,'')
left join dbo.NotaryCharge with (nolock) on NotaryCharge.NotaryID = fd.NotaryId and TotalOTR between NotaryCharge.OTRFrom and NotaryCharge.OTRUntil
and AssetTypeID = case when ProductType ='DEMotor' then 'MOTOR' else 'MOBIL'end
where IsProses = 0 and BatchNo = @BatchNo
select * from @AktaFiducia
SET @message = ''
COMMIT TRAN AKTAFiducia
END TRY
BEGIN CATCH
ROLLBACK TRAN AKTAFiducia
SET @message = ERROR_MESSAGE()
END CATCH
END