473,408 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Stored Procedure Error

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
Apr 3 '09 #1
2 2317
code green
1,726 Expert 1GB
There is a limit to how deep or how many layers
stored procedures, functions etc can call each other.
I think it is five.
It looks like you are violating this somehow.
The error may not originate from your procedure but one your procedure is actioning.
Sorry can't be of more help
Apr 7 '09 #2
ck9663
2,878 Expert 2GB
Based on the above code, you commented out this part

--exec aspdnsf_UpdateVariant

so I can only assume the nesting error is on your CURSOR. If you ran this stored proc and you have the abovementioned code uncommented, that would be the problem. SP can call itself up to a certain level. This is to prevent endless loop. And you end up a sql server running endlessly without even knowing it.

---- CK
Apr 7 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
3
by: Rhino | last post by:
I've spent the last couple of hours trying to figure out how to debug a Java stored procedure and am just going in circles. The last straw came when I got "Cannot open input stream for default"...
0
by: Rhino | last post by:
I've written several Java stored procedures now (DB2 V7.2) and I'd like to write down a few "best practices" for reference so that I will have them handy for future development. Would the...
4
by: Rhino | last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a Throwable back to the calling program as an OUT parameter? If yes, what datatype should I use when registering the...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
1
by: deepdata | last post by:
Hi, I am trying to fetch data from db2 (express version) database by calling stored procedure. I have tried to use both cursor and for loop but still i am getting error. --======Start...
7
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason...
7
by: eholz1 | last post by:
Hello PHP group, Could someone help me out? I have PHP 5.2, Apache 2.0, and MySQL 5.0 running on Linux (Redhat Fedora Core 6). All that works fine. I would like to be able to "call" a stored...
4
by: barmatt80 | last post by:
I am stumped on the error reporting with sql server. I was told i need to return @SQLCode(code showing if successful or not) and @ErrMsg(and the message returned). I am clueless on this. I...
0
by: SOI_0152 | last post by:
Hi all! Happy New Year 2008. Il hope it will bring you love and happyness I'm new on this forum. I wrote a stored procedure on mainframe using DB2 7.1.1 and IBM language c. Everything works...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.