Re: porting 4.x 4GL code to 6.01 - question
Posted in 1996
>Anything else???
YES! Watch out for bug B31661.
When migrating from 4.1x to 6.0x, watch out for statements where
you prepare an update or delete statement and reference a cursor
with WHERE CURRENT OF cursorname:
DECLARE c_select CURSOR FOR
SELECT Column1, Column2 FROM SomeTable FOR UPDATE
LET upd_stmt = "UPDATE SomeTable SET (Column1, Column2) = (?, ?)"
"WHERE CURRENT OF c_select"
PREPARE p_update FROM upd_stmt
FOREACH c_select INTO variable1, variable2
-- modify the variables
EXECUTE p_update USING variable1, variable2
END FOREACH
This will fail with a cursor not found error, unless you compiled the
module with the c4gl option "-globcurs". If you do that, you must
make sure that all your cursor names and statement names are unique
across all modules compiled with "-globcurs" in effect.
The approved way of fixing this problem is to build the upd_stmt string
with the special function CURSOR_NAME:
LET upd_stmt = "UPDATE SomeTable SET (Column1, Column2) = (?, ?)"
"WHERE CURRENT OF ", CURSOR_NAME("c_select")
This will work correctly even when cursor names are being mangled. The
CURSOR_NAME function was introduced in 4.13/6.01 (and is not available in
4.12/6.00 or earlier releases). The 4.1x version of CURSOR_NAME() does
nothing; the 6.0x version mangles the name in the same way as the c_select
cursor name is mangled -- look in the release notes for more information.
This is the fallout from bug number B31661, and the fix is not transparent
to the user, and cannot be transparent to the user. The problem arises
because cursor names are mangled in an attempt to retain the 4.1x behaviour
of cursor names being private to a source file even though the underlying
6.00 ESQL/C only supports global cursor names.
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
>Date: Tue, 16 Jan 1996 16:29:36 -0800 (PST)
>From: Alan Goodman <alan@dssmktg.com>
>X-Informix-List-Id: <list.8430>
>
>I was wondering if anyone can add to the following list of
>code changes when converting programs running under 4.1x tools to
>6.01 4GL and 7.10 online engine.
>
>Things I know about:
>1. Watch out for rowid access to records. Change to primary-key access,
>or add an explicit rowid (serial) field to the table, so if some DBA
>fragments my table my program won't die on duplicate rowids, etc.
>
>2. When freeing cursors, if the cursor was prepared, free the prepared
>string and also free the cursor. In the older tools, you just had to free
>the prepared string.
>
>3. Watch out for cursors declared using local variables in the
>where-clause.