473,398 Members | 2,393 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,398 software developers and data experts.

Procedure Too Large Error

I have a (very) complicated bit of calculation script which has just come up with the error "Procedure Too Large"

Clearly, I need to split it into smaller subroutines.

However, having never done this, I need to ask a few questions.

1. are any variants and recordsets that I have called in the initial subroutine still accessable as normal?
2. are subroutines that run within subroutines counted as part of the intial sub, and therefore would't help my intial problem anyway?
3. Do they automatically end up back where they started once the sub is finished (ie, you call a sub it executes, then the code will return to the original sub it was called from?)

Thanks
Sep 8 '11 #1
5 3987
patjones
931 Expert 512MB
Hi James,

Splitting a subroutine or function into smaller parts (technically called "functional decomposition") is good programming practice as long as it's not taken to an extreme. I suppose the compiler was written with this in mind. Extremely large procedures are unwieldy: they are harder to debug, and more difficult for programmers unfamiliar with your code...to become familiar with it. For your specific questions:
  1. Variables defined at the subroutine level are accessible only within that subroutine. There are two ways around this that I can think of. One is to declare the variables at the top of the module so that all routines within the module have access to them. Another way is to define the called routines such that they can accept arguments, and so you can pass variables in at the point where you call the routine.

  2. No.

  3. Yes. Execution picks up with the line following the subroutine or function call. One interesting point about this has to do with errors. I have had instances where if an error occurs in a called subroutine or function, VBA doesn't put up a message until it has backed out of the called code and encounters the error handling code in the calling procedure. I don't have a concrete example in mind right now, but will try and create one when I have more time.

I hope this helps a little!

Pat
Sep 8 '11 #2
Hi Pat,
Yes that does help! I was hoping that I would only need to define the variables in the top subroutine, but never mind, not too much of a hardship! I assume that same would be for recordsets that I have called?

James
Sep 8 '11 #3
NeoPa
32,556 Expert Mod 16PB
Yes James. It would.

To clarify Pat's third point a little further :
  1. If code execution hits an error within a procedure that has an error handler, that handler will handle the error.
  2. If code execution hits an error within a procedure that has no error handler, but any of the calling procedures at a higher level does have an error handler, that handler (from the higher level calling procedure) will handle the error.
  3. If code execution hits an error within a procedure that has no error handler, and no higher level calling procedures have error handlers either, the application will handle the error and the code will stop.
Sep 8 '11 #4
Rabbit
12,516 Expert Mod 8TB
How large is it exactly? I've had some pretty large procedures without running into that problem.

What is the purpose of the procedure? Perhaps we can offer suggestions on optimization.
Sep 8 '11 #5
Mihail
759 512MB
Do not forget about FUNCTIONS.
The functions design is the same of a subroutine (with arguments as usual in math). And a function return a value based on arguments you pass. It is the most elegant way to split a procedure.
Sep 9 '11 #6

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

Similar topics

0
by: cschang | last post by:
My system is on a NT4 (w/SP6a) running IIS 4. I am developing a page that query one record from my Oracle DB 8.1.6 on a separate machine. I am using the MS ODBC for Oracle drive. In my ASP page...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
1
by: Randy Harris | last post by:
I've been fighting a problem with A2K for weeks now and am absolutely stumped. I have a procedure that is called from the Activate event of a form. The procedure creates a couple of recordsets,...
6
by: Paul | last post by:
Hi there, When adding a "File Field" HTML control to an aspx page to facilitate file uploading, the following occurs: 1. You select a file that is larger than the allowed size limit. 2. Once...
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...
9
by: sparks | last post by:
I have a table in 2003 that has 221 fields defined. I tried to add another variable and got this error. I was surprised when it didn't say too many fields defined. I look at the error...
0
by: %NAME% | last post by:
Hi, I am trying to create stored procedure in DB2. I am using version v7.1.0.40, on Solaris. The procedure is written in SQL PL and is very simple. However, I could not build it. I got...
10
by: darrel | last post by:
Hi can somebody tell me how can i resolve my "PROCEDURE TOO LARGE ERROR",,, my code is too large.. how can i resolve it.
4
by: dstorms | last post by:
Hi, I'm trying to create a form with a list box with 2 columns and a button that opens the selected record in the appropriate form. In the sample below, the first column lists the type of equipment...
13
by: sasasasa | last post by:
Hi, I am getting the error saying 'Invalid Procedure Call' in my query. My query is very simple. I am just getting data from another query which is getting data from a table. SELECT ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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,...

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.