Re: case 787122: Problem after FREEING prepared stmt in Dynamic-4GL
Posted in 1998
In article <714tbc$23j$1@news.xmission.com>, Colin M McGrath <cmm@trac3000.ueci.com> writes > >--%#%record%#% >Content-Type: text/plain; charset=US-ASCII >Content-Transfer-Encoding: 7bit >Content-Length: 2557 > >Are we doing something wrong in our classical 4GL programs, or is >something wrong with the behaviour of Dynamic-4gl? > > We have: An RS6000 running AIX 4.3.1 with: > INFORMIX-OnLine Version 5.10.UC1 > INFORMIX-4GL RDS Version 4.20.UC1 > INFORMIX-4GL Version 4.20.UC1 > Informix-Dynamic-4GL Version 2.01.UC1 > >We use "CONSTRUCT BY NAME" to generate a where-clause string that we combine >with another string to create a SELECT string. We PREPARE a STATEMENT from >the select string and DECLARE a CURSOR for the STATEMENT. We populate an >array via a FOREACH loop using the cursor, then we FREE the STATEMENT. > >In 4GL and 4GL-RDS the FREE statment doesn't hurt (and hopefully helps). >Every time the function with the CONSTRUCT is called up, a call occurs to the >function that creates the STATEMENT and the CURSOR and populates the lookup >array. > >There is no problem the first time the FOREACH loop is hit. But the second >entry into the FOREACH loop (in Dynamic-4gl ONLY) gives the error: > > Program stopped at "lu_lookup.4gl", line number 320. > SQL statement error number -404. > The cursor or statement is not available. > > Running Dynamic-4GL with its debugger shows that right after the PREPARE >and DECLARE lines, the SQLCA.SQLCODE = 0. > > PREPARE lookup_stmt FROM c_txt > DECLARE lookup_curs CURSOR FOR lookup_stmt > > LET lookup_cnt = 1 > FOREACH lookup_curs INTO p_lookup[lookup_cnt].cde, > p_lookup[lookup_cnt].sdesc > LET p_lookup[c_lookup].mark = NULL > LET c_lookup = c_lookup + 1 > IF c_lookup > 500 THEN > EXIT FOREACH > END IF > END FOREACH > LET c_lookup = c_lookup - 1 > FREE lookup_curs > FREE lookup_stmt > >So why the error -404 the second time the FOREACH line is hit? >What versions of 4GL/OnLine should both the cursor and stmt be freed? >Are we correct in freeing the stmt in our version? > I belive under 4gl 6.x (and hence probably D4GL) you need to free the cursor as well.. >Included is a base64 encoded tar file of a small 4GL, PER and two small table >unloads that duplicate the problem. (Control-C exits the program in 4GL, >2nd query bombs the program in D4GL.) > -- David Williams Maintainer of the Informix FAQ Primary site (Beta Version) http://www.smooth1.demon.co.uk Official site http://www.iiug.org/techinfo/faq/faq_top.html I see you standin', Standin' on your own, It's such a lonely place for you, For you to be If you need a shoulder, Or if you need a friend, I'll be here standing, Until the bitter end... So don't chastise me Or think I, I mean you harm... All I ever wanted Was for you To know that I care