Re: open cursor ==> error -255/0
Posted in 1997
Nils & all, First, thank you for your comments. I agree there is something suspicious about the code but I was reluctant to rewrite the entire application. The code in which the "whenever error continue" was in effect was done this way only to allow me to properly see the error codes via the debugger; the normal behavior is "call error_handler". If you have not been following this thread (I admit to occasional sesquepedelian verbosity ;-) what follow will be gibberish, because I will be snipping away most of the previous traffic. Nils Myklebust wrote: --SNIP-- > :542 whenever error continue # For debugging > :543 > :544 close pkey_curs # This was opened in llh_a_construct > :545 open pkey_curs # reopen it for fresh business > :546 while sqlca.sqlcode = 0 > The first time this sqlcode is from the above open statement which is > ok. The next time arround it's from the clos lh_cursor just before the > end while. That I assume is not the idea. > :547 fetch pkey_curs > :548 into m_oordrh.ord_num # Just get the primary key value > You may use: > if sqlca.sqlcode <> 0 then > exit while > end if > to get out of the while loop. Actually, Nils, this code was working without a problem; it was ONLY the following line that blew up in my face: > :549 open lh_cursor > :550 using m_oordrh.ord_num The above was getting the -255 error. -- SNIP -- > As you apperantly have transactions turned on in the database it's > strange to program the way you have done. As you are locking each row > I assume some kind of update (perhaps including insert/delete) happens > somewhere (in the approve_nsrs function). > As you have no begin work each update will be treated as a separate > transaction. At this time all your cursors will be automatically > closed, including your main pkey_curs. This should therefore be > declared as a hold cursor. Nils, I will cut your remark down to onw sentence, most uncharacteristic of me. ;-) I need to be *in* a transaction in order to open a locking cursor. ***************************************************************** Whoops! Shame on me! :-( In further debugging, I stuck a BEGIN WORK before the "open lh_cursor". No error opening the cursor. Fortunately, I was able to restucture toe code to completely eliminate the need for lh_cursor. Hey, cop-outs have a place in business! Thanks for the suggestions which pointed me to a subtle oversight. Even looking in the "Guide to SQL - Syntax" I could not find a reference to this requirement. Grumble! Again: Thank you, Nils, for having the patience to read through a long posting. -- -- Jake (A chastened village idiot) . . _..-'( )`-.._ ./'. '||\\\\. }\\_/{ .//||` .`\\. ./'.|'.'||||\\\\|.. )o o( ..|//||||`.`|.`\\. ./'..|'.|| |||||\\`````` \\'@'/ ''''''/||||| ||.`|..`\\. ./'.||'.|||| ||||||||||||. | .|||||||||||| ||||.`||.`\\. /'|||'.|||||| ||||||||||||{ | }|||||||||||| ||||||.`|||`\\ '.|||'.||||||| ||||||||||||{ | }|||||||||||| |||||||.`|||.` '.||| ||||||||| |/' ``\\||`` | ''||/'' `\\| ||||||||| |||.` |/' \\./' `\\./ \\!|\\ /|!/ \\./' `\\./ `\\| V V V }' `\\ /' `{ V V V \\ \\ \\ V / / / +-----------------------------------------------------------+ | Impeccable Logic: A thought process which successfully | | resists chicken bites | +-----------------------------------------------------------+