简体   繁体   English

语法接近0

[英]Incorrect Syntax near 0

Im getting this error message I've tried to look at my code I cant seem to see where its coming from, please help. 我收到此错误消息,我试图查看我的代码,但似乎看不到它的来源,请帮忙。

ERROR:- 错误:-

Msg 102, Level 15, State 1, Procedure _TESTbspPostAPTrans, Line 249 Incorrect syntax near '0'. 消息102,级别15,状态1,过程_TESTbspPostAPTrans,行249靠近“ 0”的语法错误。

SET ANSI_NULLS ON
GO
CREATE procedure [dbo].[_TESTbspPostAPTrans]
  @AutoIdx bigint = NULL OUTPUT,
  @TxDate datetime,
  @Id varchar(5),
  @AccountLink int,
  @TrCodeID int,
  @Debit float,
  @Credit float,
  @CurrencyID int,
  @ExchangeRate float,
  @ForeignDebit float,
  @ForeignCredit float,
  @Description varchar(100),
  @TaxTypeID int,
  @Reference varchar(50),
  @Order_No varchar(50),
  @ExtOrderNum varchar(50),
  @AuditNumber varchar(50),
  @Tax_Amount float,
  @ForeignTaxAmount float,
  @Project int,
  @Outstanding float,
  @ForeignOutstanding float,
  @InvNumKey bigint,
  @UserName varchar(20),
  @Reference2 varchar(50),
  @SettlementTermsID int,
  @TxBranchID int,
  @GLTaxAccountID int = 0,
  @cLineUserFields varchar (max) = ''


as
set nocount on
set identity_insert PostAP on
if (IsNull(@AccountLink, 0) = 0) begin
  RAISERROR('_bspPostAPTrans: No Accounts Payable Account specified!', 16, 1)
  return 0
end
else
if (IsNull(@Id, '') = '') begin
  RAISERROR('_bspPostAPTrans: No Transaction ID specified!', 16, 1)
  return 0
end
else
if (IsNull(@TrCodeID, 0) = 0) begin
  RAISERROR('_bspPostAPTrans: No Transaction Code specified!', 16, 1)
  return 0
end
else
if (IsNull(@AuditNumber, '') = '') begin
  RAISERROR('_bspPostAPTrans: No Audit Trail Number specified!', 16, 1)
  return 0
end
--begin tran --CC: Will now be controlled in Code
declare @SPError int
declare @BranchID int
select @BranchID = Vendor_iBranchID from Vendor where DCLink = @AccountLink
if isnull(@AutoIdx, 0) <= 0 begin
if isnull (@AccountLink, 0) = 4917 begin
        set nocount on
        set identity_insert PostAR on
        --begin tran --CC: Will now be controlled in Code
        select @BranchID = Client_iBranchID from Client where DCLink = @AccountLink
        select @AutoIdx = ident_current('PostAR') + 1
        insert into PostAR
              (
              AutoIdx,
              TxDate,
              [Id],
              AccountLink,
              TrCodeID,
              Debit,
              Credit,
              iCurrencyID,
              fExchangeRate,
              fForeignDebit,
              fForeignCredit,
              [Description],
              TaxTypeID,
              Reference,
              Order_No,
              ExtOrderNum,
              cAuditNumber,
              Tax_Amount,
              fForeignTax,
              Project,
              Outstanding,
              fForeignOutstanding,
              InvNumKey,
               UserName,
              cReference2,
              iPostSettlementTermsID,
              iTxBranchID,
              iGLTaxAccountID
                )
            values
              (
              @AutoIdx,
              @TxDate,
              @Id,
              @AccountLink,
              @TrCodeID,
              @Debit,
              @Credit,
              @CurrencyID,
              @ExchangeRate,
              @ForeignDebit,
              @ForeignCredit,
              @Description,
              @TaxTypeID,
              @Reference,
              @Order_No,
              @ExtOrderNum,
              @AuditNumber,
              @Tax_Amount,
              @ForeignTaxAmount,
              @Project,
              @Outstanding,
              @ForeignOutstanding,
              @InvNumKey,
              @UserName,
              @Reference2,
              @SettlementTermsID,
              @TxBranchID,
              @GLTaxAccountID

              )

                set @SPError = @@ERROR
                set identity_insert PostAR off

            -- Post User Defined Fields
            if (len (@cLineUserFields) > 0) begin
              declare @UDFSQLText1 varchar(max)
              set @UDFSQLText1  =  'update PostAR set ' + @cLineUserFields + '  where AutoIdx = ' + CAST(@AutoIdx as varchar)
              execute (@UDFSQLText1)
              set @SPError = @@ERROR
              if @SPError <> 0 goto AbortTran
              -- Update Client Balances
             end 
              UPDATE dbo.Client
              SET DCBalance = Round(IsNull (DCBalance, 0) + (@Debit - @Credit), 4),
              fForeignBalance = Round(IsNull(fForeignBalance, 0) + (@ForeignDebit - @ForeignCredit), 4)
              WHERE DCLink = @AccountLink
              set @SPError = @@ERROR
              if @SPError <> 0 goto AbortTran1
              goto CommitTran1
              --rollback tran --CC: Will now be controlled in Code
              RAISERROR (@SPError, 16, 1)
              return @SPError
              if @SPError <> 0 goto AbortTran


 END

  select @AutoIdx = ident_current('PostAP') + 1
insert into PostAP
  (
  AutoIdx,
  TxDate,
  [Id],
  AccountLink,
  TrCodeID,
  Debit,
  Credit,
  iCurrencyID,
  fExchangeRate,
  fForeignDebit,
  fForeignCredit,
  [Description],
  TaxTypeID,
  Reference,
  Order_No,
  ExtOrderNum,
  cAuditNumber,
  Tax_Amount,
  fForeignTax,
  Project,
  Outstanding,
  fForeignOutstanding,
  InvNumKey,
  DTStamp,
  UserName,
  cReference2,
  iPostSettlementTermsID,
  PostAP_iBranchID,
  iTxBranchID,
  iGLTaxAccountID
  )
values
  (
  @AutoIdx,
  @TxDate,
  @Id,
  @AccountLink,
  @TrCodeID,
  @Debit,
  @Credit,
  @CurrencyID,
  @ExchangeRate,
  @ForeignDebit,
  @ForeignCredit,
  @Description,
  @TaxTypeID,
  @Reference,
  @Order_No,
  @ExtOrderNum,
  @AuditNumber,
  @Tax_Amount,
  @ForeignTaxAmount,
  @Project,
  @Outstanding,
  @ForeignOutstanding,
  @InvNumKey,
  GetDate(),
  @UserName,
  @Reference2,
  @SettlementTermsID,
  @BranchID,
  @TxBranchID,
  @GLTaxAccountID
  )
set @SPError = @@ERROR
set identity_insert PostAP off
if @SPError <> 0 goto AbortTran1
-- Post User Defined Fields
if (len (@cLineUserFields) > 0) begin
  declare @UDFSQLText varchar(max)
  set @UDFSQLText  =  'update PostAP set ' + @cLineUserFields + '  where AutoIdx = ' + CAST(@AutoIdx as varchar)
  execute (@UDFSQLText)
  set @SPError = @@ERROR
  if @SPError <> 0 goto AbortTran1
end
-- Update Vendor Balances
UPDATE VENDOR
SET DCBalance = Round(IsNull (DCBalance, 0) + (@Credit - @Debit), 4),
  fForeignBalance = Round(IsNull(fForeignBalance, 0) + (@ForeignCredit - @ForeignDebit), 4)
WHERE DCLink = @AccountLink
set @SPError = @@ERROR
if @SPError <> 0 goto AbortTran1
goto CommitTran1
AbortTran1:
  --rollback tran --CC: Will now be controlled in Code
  RAISERROR (@SPError, 16, 1)
  return @SPError
CommitTran1:
  --commit tran --CC: Will now be controlled in Code
  return 0 --scope_identity() -- return can only return an int, not a bigint,
           -- AutoIdx has been added as a paramater for the BA sync and is an OUTPUT paramter

GO

Any help will be greatly appreciated 任何帮助将不胜感激

我认为在第62和63行中您有2个BEGIN打开,第159行中只有第一个END 。在第160行中缺少END

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM