2017-05-09 7 views
0

このエラーメッセージが表示されています私は自分のコードを調べようとしましたが、どこから来たのか分かりません。不適切な構文0付近

ERROR: -

Msg 102, Level 15, State 1, Procedure _TESTbspPostAPTrans, Line 249 Incorrect syntax near '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 

すべてのヘルプは大幅に

答えて

0

を理解されるであろう、私はライン62と63であなたは2ライン159.on ENDにちょうど最初のENDBEGINを開いたと思います行160に欠けている

+0

ありがとう、はい、問題だった、ありがとう、ありがとう。 – Cynthia

+0

@Cynthiaこれはあなたのために働く場合、あなたは投票し、正解としてそ​​れを受け入れることができます! –

関連する問題