Re: Problems with error 4518
Posted in 1993
There is another condition in addition to the ones listed in Loren's article. This condition is where you have a CASE statement that "falls through". By the term "fall through" I mean that none of the WHEN clauses are executed and there is not an OTHERWISE statement. Good luck. ---- original message from Kristjan Gaukur Kristjansson ---- ++ ++ ++ > Any ideas? ++ ++ > Thanks in advance.... ++ ++ > Alfonso ++ ++ Here is an article I picked from the group last year, hope that it helps ++ (it did for me...). ++ ++ >From comp.databases.informix Thu Dec 10 17:39:00 1992 ++ Path: krafla!isgate!sunic!mcsun!uunet!stanford.edu!rutgers!cmcl2!panix!clay ++ From: clay@panix.com (Clay Irving) ++ Newsgroups: comp.databases.informix ++ Subject: Excellent article on Temp. String Space ++ Keywords: Temporary String Space ++ Message-ID: <1992Dec9.231353.2343@panix.com> ++ Date: 9 Dec 92 23:13:53 GMT ++ Organization: PANIX Public Access Unix, NYC ++ Lines: 193 ++ ++ I've found this to be an excellent discussion of temporary string space in ++ Informix-4GL. The author is Loren West of FourGen Software, Inc. ++ (uunet!4gen!lorenw) ++ ++ Temporary String Space (TSS) ++ ---------------------------- ++ by Loren West ++ ++ My understanding of how Informix handles Temporary String Space has increased ++ dramatically over the last couple of months, and I'd like to share that ++ information for anyone (everyone) that has ever had a string space problem. ++ ++ 1) TSS in Informix is limted. It is only about 4K or so. ++ ++ 2) Very few things require TSS. Usually, those things use it, then clear the ++ entire TSS when they're done. In my opinion, Informix's 4K limit on TSS is ++ adequate. It only becomes a problem under certain (and completely avoidable) ++ circumstances. ++ ++ 3) TSS is used in the following scenarios: ++ ++ A) Passing strings to, and returning strings from functions. ++ ++ B) Internal scratchpad usage within certain 4GL commands. ++ ++ * Scenario (A) is blamed for 4GL running out of temporary string space. It ++ also, usually, is not the source of the problem. ++ ++ 4) In order to understand the source of the problem, it's important to ++ understand how temp string space is used, and when it's cleared. ++ ++ When a string is passed to a 4GL function, the calling function places it into ++ TSS. IMMEDIATELY upon invocation, the called function retrieves it into a ++ local variable, and (and this is the key) if there is nothing else in TSS, the ++ ENTIRE TSS is cleared and reset. ++ ++ IF there is something else in TSS, it waits until that something is used, THEN ++ it resets TSS. IF that something never uses it, then you get the out of string ++ space problem. ++ ++ The following example shows normal TSS usage: ++ ++ 1 main ++ 2 call myfunct("Hello") ++ 3 end main ++ 4 ++ 5 function myfunct(str_var) ++ 6 define ++ 7 str_var char(20) ++ 8 display str_var clipped, " World" ++ 9 end function ++ ++ In the above example, line 2 places the string "Hello" into TSS. Line 7 ++ actually retrieves "Hello" from TSS, puts it into the local str_var variable, ++ and because there is nothing else in TSS, it is cleared and reset. ++ ++ Line 8 puts str_var into TSS, then puts " World" into TSS, then calls (an ++ internal 4GL) display function. This display function retrieves "Hello" from ++ TSS, then retrieves " World" from TSS, then (because there is nothing else on ++ the stack) clears and resets TSS. It then goes about it's business of ++ displaying "Hello World" onto the screen. ++ ++ The following example shows how you can get into trouble with TSS: ++ ++ 1 main ++ 2 define ++ 3 local_var char(20) ++ 4 let local_var = "Hello", myfunct(" World") ++ 5 end main ++ 6 ++ 7 function myfunct(str_var) ++ 8 define ++ 9 str_var char(20) ++ 10 return str_var ++ 11 end function ++ ++ In line 4, the "Hello" string is put into TSS (for the `let' command), then ++ " World" is placed into TSS for the function call to myfunct(). ++ ++ The difference here is line 9. When " World" is removed from TSS, it is not ++ cleared because "Hello" is still there. In line 10, TSS is used again to ++ return the string " World" back to the calling function. At this point, TSS ++ contains the following: ++ "Hello" ++ " World" ++ " World" ++ ++ When myfunct() returns, " World" is taken from the TSS, then put back into the ++ TSS for the let command to process. At this time, TSS looks like: ++ "Hello" ++ " World" ++ " World" ++ " World" ++ ++ Finally, the let command gets the " World", then the "Hello", and when it gets ++ the "Hello", the TSS is cleared. This is a normal situation. It uses TSS, but ++ not much, and it is appropriately cleared after the `let' command is done ++ processing. ++ ++ The problem that can arise using this syntax is if the myfunct() command ++ doesn't return right away. If myfunct() calls alot of different function, and ++ if those functions consume any TSS, then it will not be reset until the first ++ `let' command has finished processing. You're very likely to get a string space ++ error in this scenario. ++ ++ 5) The following scenarios will result in an out of string space error if the ++ function that is called is a "string hog" (a string hog function is one that ++ uses TSS alot - not necessarily one that uses alot of TSS, but one that uses ++ TSS alot): ++ ++ A) Calling a function from within a string concatenation" ++ This will error: ++ let a_string="Hello",string_hog() ++ ++ This will not: ++ let temp_string=myfunct() ++ let a_string="String",temp_str ++ ++ B) Using the `case' command with a string argument. ++ This will error: ++ case a_string ++ when "A" ++ display "OK" ++ when "B" ++ call string_hog() ++ end case ++ ++ This will not: ++ case ++ when a_string="A" ++ display "OK" ++ when a_string="B" ++ call string_hog() ++ end case ++ ++ Note also that the `using' keyword can be categorized as a `string hog' ++ function. This doesn't mean that it inappropriately uses TSS, it just uses ++ alot. ++ ++ 6) In most cases, finding the source of the string space error is incredibly ++ difficult. It usually is caused in a function far away from the place that ++ the program actually fails. ++ ++ What follows is a function that is guaranteed to work if TSS is clear, and is ++ guaranteed to f