Re: case 787122: Problem after FREEING prepared stmt in Dynamic-4GL
Posted in 1998
David Williams wrote: > I belive under 4gl 6.x (and hence probably D4GL) you need to free the > cursor as well.. Tried that, still same error -404. Plus, given the version we have (see list below), should we be freeing both? Isn't freeing memory twice asking for eventual core dumps? > In article <714tbc$23j$1@news.xmission.com>, Colin M McGrath > <cmm@trac3000.ueci.com> writes > > > >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? -- ______________________________________________________________________ | Colin McGrath cmm@trac3000.ueci.com | | Raytheon Engineers & Constructors, Inc. (215) 422-4144 | | Phila, PA, USA | | Any opinions I state are my own and not necessarily of my employer | |____________________________________________________________________|