Dev Try
Dev Try

Reputation: 211

Procedure call inside procedure

First I need to check if spOBJ_CopyInspectiontask has any errors, if there are no errors, only then proceed to the insert statement.

DECLARE @tblSystemId TABLE
                     (
                         OldSysId int, NewSysId int,
                         OldTaskId int, NewTaskId int,
                         TaskObjectIds varchar(max) null
                     );

INSERT INTO @tblSystemId (OldSysId , NewSysId, OldTaskId, NewTaskId, TaskObjectIds)            
    EXEC dbo.spOBJ_CopyInspectiontask @UserId, @TargetCustomerId, @TargetContractId, @TargetSiteId, @SourceCustomerId, @OldTaskId, @SystemName, @Checkall, @CopyReports, @Return OUTPUT, @ObjectIds OUTPUT;

How can I check that?

Upvotes: 0

Views: 42

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269493

Perhaps you want a try/catch block:

BEGIN TRY
    INSERT INTO @tblSystemId (OldSysId , NewSysId, OldTaskId, NewTaskId,TaskObjectIds )            
        EXEC dbo.spOBJ_CopyInspectiontask @UserId,@TargetCustomerId, @TargetContractId, @TargetSiteId,
             @SourceCustomerId, @OldTaskId, @SystemName, @Checkall, @CopyReports, @Return OUTPUT, @ObjectIds OUTPUT;
END TRY
BEGIN CATCH
    -- do something here in the event of failure
END CATCH;

Upvotes: 2

Related Questions