我已经看过这些帖子并试图解决这个问题,但却无法解决。所以这是代码。帮助解决问题。
我有一个程序调用另一个程序。
来电程序:
ALTER PROCEDURE [dbo].[DadSaveMembership]
@PERSON AS [dbo].[Person_Master_Type] Readonly,
@ADDRESS AS [dbo].[Address_Master_Type] Readonly,
@MEMBERSHIP AS [dbo].[Membership_Type] Readonly
AS
BEGIN
declare @pid int, @aid int, @CUR_PID int, @CUR_ADD int, @atype int, @created_by int
declare @created_date date
select @pid=person_id from @PERSON
select @aid=address_id from @ADDRESS
if(@pid=0)
begin
INSERT INTO PERSON_MASTER (TITLE,FNAME,MNAME,LNAME,DOB,GENDER,MARITALSTATUS,MOBILE,EMAIL,CREATED_BY,CREATED_DATE)
SELECT TITLE,FNAME,MNAME,LNAME,DOB,GENDER,MARITALSTATUS,MOBILE,EMAIL,CREATED_BY,CREATED_DATE FROM @PERSON
SELECT @CUR_PID=MAX(PERSON_ID) FROM PERSON_MASTER
end
else
begin
set @CUR_PID=@pid
end
if(@aid=0)
begin
INSERT INTO ADDRESS_MASTER (ADDRESS1,ADDRESS2,ADDRESS3,CITY_ID,PINCODE,PHONE,CREATED_BY,CREATED_DATE)
SELECT ADDRESS1,ADDRESS2,ADDRESS3,CITY_ID,PINCODE,PHONE,CREATED_BY,CREATED_DATE FROM @ADDRESS
SELECT @CUR_ADD=MAX(ADDRESS_ID) FROM ADDRESS_MASTER
end
else
begin
set @CUR_ADD=@aid
end
EXEC [dbo].[GET_DAD_COUNT_AID$IMPL$AUTO] @CUR_PID, "3", @CUR_ADD, @atype OUTPUT
INSERT INTO PERSON_MODULE_LINK (PERSON_ID,MODULE_ID,ADDRESS_ID,ADDRESS_TYPE,CREATED_BY,CREATED_DATE)
VALUES (@CUR_PID,3,@CUR_ADD,@atype,@CREATED_BY,@CREATED_DATE)
END
另一个程序如下
ALTER PROCEDURE [dbo].[GET_DAD_COUNT_AID$IMPL$AUTO]
@pid int,
@modid int,
@addrid int,
@return_value_argument int OUTPUT
AS
BEGIN
SET IMPLICIT_TRANSACTIONS ON
DECLARE
@cnt int,
@cnt1 int
SELECT @cnt1 = isnull(max(CAST(ADDRESS_HISTORY_DETAIL.ADDRESS_TYPE AS numeric(38, 10))), 0)
FROM dbo.ADDRESS_HISTORY_DETAIL
WHERE
ADDRESS_HISTORY_DETAIL.PERSON_ID = @pid AND
ADDRESS_HISTORY_DETAIL.MODULE_ID = @modid AND
ADDRESS_HISTORY_DETAIL.ADDRESS_ID = @addrid
SELECT @cnt = isnull(max(CAST(PERSON_MODULE_LINK.ADDRESS_TYPE AS numeric(38, 10))), 0)
FROM dbo.PERSON_MODULE_LINK
WHERE
PERSON_MODULE_LINK.PERSON_ID = @pid AND
PERSON_MODULE_LINK.MODULE_ID = @modid AND
PERSON_MODULE_LINK.ADDRESS_ID = @addrid
IF @cnt1 > @cnt
BEGIN
SET @return_value_argument = @cnt1+1
RETURN
END
ELSE
BEGIN
SET @return_value_argument = @cnt+1
RETURN
END
END
问题是我在调用DadSaveMembership SP时遇到以下错误: 超时已过期。操作完成之前经过的超时时间或服务器没有响应。那么,出了什么问题?
答案 0 :(得分:0)
我怀疑问题是 GET_DAD_COUNT_AID $ IMPL $ AUTO 存储过程中的SET IMPLICIT_TRANSACTIONS ON
命令。读取MSDN看来,通过设置命令并执行SELECT命令,可以创建事务但从未提交或回滚。您可以将原始SP包装在事务BEGIN TRANSACTION
+ COMMIT
/ ROLLBACK
中,也可以将所有语句一起删除。
您还应考虑更换这两个陈述:
SELECT @CUR_ADD=MAX(ADDRESS_ID) FROM ADDRESS_MASTER
SELECT @CUR_PID=MAX(PERSON_ID) FROM PERSON_MASTER
用这些:
SELECT @CUR_ADD = SCOPE_IDENTITY()
SELECT @CUR_PID = SCOPE_IDENTITY()