Hi,
I have written a Stored Procedure. I'm getting the error as below.
Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).
Can any one give me a solution for this problem I have given the procedure below.
ALTER procedure [dbo].[aspdnsf_UpdateVariant]
as
begin
DECLARE @Price money, @SalePrice money, @Inventory int, @SKUSuffix nvarchar(50)
DECLARE @ROWCOUNT as int
set @ROWCOUNT=(select count(*) from ProductVariant as Variant
where Variant.ManufacturerPartNumber = Variant.SKUSuffix)
IF(@ROWCOUNT>0)
begin
DECLARE move_Product_Variant_Cursor CURSOR FOR
select Price, SalePrice , Inventory ,SKUSuffix from ProductVariant as Variant
where Variant.ManufacturerPartNumber = Variant.SKUSuffix
OPEN move_Product_Variant_Cursor
FETCH NEXT FROM move_Product_Variant_Cursor INTO @Price, @SalePrice , @Inventory, @SKUSuffix
--Fetch next record
WHILE @@FETCH_STATUS = 0
BEGIN
-- here do something like calling a stored procedure or whatever,
-- using the variable you just set, for example:
--exec aspdnsf_UpdateVariant
-- Update ProductVariant set Price=@Price, SalePrice=@SalePrice , Inventory=@Inventory
-- where SKUSuffix=@SKUSuffix and SKUSuffix<>ManufacturerPartNumber
Update ProductVariant set Price=@Price, SalePrice=@SalePrice , Inventory=@Inventory
where ManufacturerPartNumber=@SKUSuffix and SKUSuffix<>ManufacturerPartNumber
-- now move the cursor
FETCH NEXT FROM move_Product_Variant_Cursor INTO @Price, @SalePrice , @Inventory, @SKUSuffix
--print @@FETCH_STATUS
END
CLOSE move_Product_Variant_Cursor --Close cursor
DEALLOCATE move_Product_Variant_Cursor --Deallocate cursor
end
END
Regards,
Jegan