我的存储过程无法插入声明的表格类型,已经有插入查询但是当我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