Link to home
Start Free TrialLog in
Avatar of Juan Velasquez
Juan VelasquezFlag for United States of America

asked on

Stored procedure is skipping a nested stored procedure

Hello,

When I call the attached stored procedure, EXEC sp_SupportTeamDataInsert is not being executed.  I have performed the following test with these results

In all cases EXEC sp_DistributionTableInsert executes.  However, it looks like EXEC sp_SupportTeamDataInsert is not executed.  When I execute just EXEC sp_SupportTeamDataInsert, that sproc works fine.  This is in a MS SQL Server 2005 environment
ALTER PROCEDURE [dbo].[sp_PopulateDistributionTable]
AS
TRUNCATE TABLE Distribution
BEGIN TRAN
	BEGIN TRY
		EXEC sp_DistributionTableInsert
		EXEC sp_SupportTeamDataInsert
		DELETE FROM Distribution Where LastPostedDate < POPStart 
		DELETE D FROM Distribution D
		INNER JOIN TaskOrderContributions TOC
		ON D.TaskOrder = TOC.TaskOrder
		WHERE TOC.Eligible = 0
		COMMIT TRAN
	END TRY
	
	BEGIN CATCH
		RAISERROR('Transaction Aborted', 16, 1)
		ROLLBACK TRANSACTION
	END CATCH



ALTER PROCEDURE [dbo].[sp_SupportTeamDataInsert]

AS

DECLARE curTaskOrder CURSOR FORWARD_ONLY
FOR SELECT DISTINCT TaskOrder from vwCSIB_ShareAllocationEligibleEmployees
DECLARE @TaskOrder NVARCHAR(50)
OPEN curTaskOrder
FETCH NEXT FROM curTaskOrder INTO @TaskOrder
WHILE @@Fetch_Status = 0
BEGIN
	EXEC spDistributionTableSupportTeamInsert @TaskOrder
	FETCH NEXT FROM curTaskOrder INTO @TaskOrder
END
CLOSE curTaskOrder
DEALLOCATE curTaskOrder 

GO

Open in new window

SOLUTION
Avatar of radcaesar
radcaesar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Juan Velasquez

ASKER

I found the problem - there was no problem save for staring at the code for two long.
Please explain the problem clearly.