1

我收到有关提交的异常,但不确定我的存储过程到底出了什么问题。我已经阅读了其他问题的答案,但无法找到提交计数到底在哪里弄乱了。

我使用的存储过程如下:

USE [AFS_GROUP]
GO
/****** Object:  StoredProcedure [dbo].[SBO_SP_TransactionNotification]    Script Date: 12/12/2012 10:41:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[SBO_SP_TransactionNotification] 

@object_type nvarchar(20),              -- SBO Object Type
@transaction_type nchar(1),         -- [A]dd, [U]pdate, [D]elete, [C]ancel, C[L]ose
@num_of_cols_in_key int,
@list_of_key_cols_tab_del nvarchar(255),
@list_of_cols_val_tab_del nvarchar(255)

AS

begin

-- Return values
declare @error  int             -- Result (0 for no error)
declare @error_message nvarchar (200)       -- Error string to be displayed
select @error = 0
select @error_message = N'Ok'

IF @object_type = 13 AND @transaction_type = 'A'
BEGIN
  UPDATE INV1   
  SET U_jnl1='N', U_jnl2='N', U_jnl3='N', U_jnl4='N'
  WHERE DocEntry = @list_of_cols_val_tab_del    

  DECLARE @CallIDo13 VARCHAR(10) = (SELECT TOP 1 [U_HEATID] FROM OINV WHERE [DocEntry] = @list_of_cols_val_tab_del);
  DECLARE @DocNumo13 VARCHAR(MAX) = (SELECT TOP 1 [DocNum] FROM OINV WHERE [DocEntry] = @list_of_cols_val_tab_del);
  EXEC [AFSJHBSQL01].[HEAT].[dbo].[uspCreateJournalFromINV] @CallIDo13, @DocNumo13, @object_type;
END
ELSE IF @object_type = 14 AND @transaction_type = 'A'
BEGIN
  UPDATE RIN1
  SET U_jnl1='N', U_jnl2='N', U_jnl3='N', U_jnl4='N'
  WHERE DocEntry = @list_of_cols_val_tab_del
END
ELSE IF @object_type = 15 AND @transaction_type = 'A'
BEGIN
  UPDATE DLN1
  SET U_jnl1='N', U_jnl2='N', U_jnl3='N', U_jnl4='N'
  WHERE DocEntry = @list_of_cols_val_tab_del    

  DECLARE @CallIDo15 VARCHAR(10) = (SELECT TOP 1 [U_HEATID] FROM ODLN WHERE DocEntry = @list_of_cols_val_tab_del);
  DECLARE @DocNumo15 VARCHAR(MAX) = (SELECT TOP 1 [DocNum] FROM ODLN WHERE DocEntry = @list_of_cols_val_tab_del);
  EXEC [AFSJHBSQL01].[HEAT].[dbo].[uspCreateJournalFromDN] @CallIDo15, @DocNumo15, @object_type;
END
ELSE IF @object_type = 16 AND @transaction_type = 'A'
BEGIN
  UPDATE RDN1
  SET U_jnl1='N', U_jnl2='N', U_jnl3='N', U_jnl4='N'
  WHERE DocEntry = @list_of_cols_val_tab_del
END
ELSE IF @object_type = 17 AND @transaction_type = 'A'
BEGIN
  DECLARE @ItemCode VARCHAR(MAX) = (SELECT TOP 1 [ItemCode] FROM [RDR1] WHERE [DocEntry] = @list_of_cols_val_tab_del AND ([ItemCode] = 'VIU Chip Prod' OR [ItemCode] = 'FPR Chip Production'));
  DECLARE @Desc VARCHAR(MAX) = (SELECT TOP 1 [CardName] FROM ORDR WHERE [DocEntry] = @list_of_cols_val_tab_del);
  --DECLARE @CallID VARCHAR(10) = (SELECT TOP 1 [U_HEATID] FROM ORDR WHERE [DocEntry] = @list_of_cols_val_tab_del);
  IF (@ItemCode = 'VIU Chip Prod')
  BEGIN
      EXEC [AFSJHBSQL01].[HEAT].[dbo].[uspCreateHeatJobFromSO] @list_of_cols_val_tab_del, @ItemCode, @Desc;
      --RETURN;
  END
  ELSE IF(@ItemCode = 'FPR Chip Production')
  BEGIN
      EXEC [AFSJHBSQL01].[HEAT].[dbo].[uspCreateHeatJobFromSO] @list_of_cols_val_tab_del, @ItemCode, @Desc;
    --RETURN;
  END
END
--------------------------------------------------------------------------------------------------------------------------------
-- Select the return values
select @error, @error_message
END
4

0 回答 0