RE: Cursors...
Posted in 1999
It's not a good idea to declare a cursor over and over again within a
program (as you are finding out) without 'free'ing it later.
You can free the cursor just before the end of the first foreach, or
even better, declare the cursor once at the beginning of the program,
and then 'open' it 'using' rec_a.key.
HTH
-----Original Message-----
From: Guido Cirilli [SMTP:g.cirilli@tdnet.it]
Posted At: Friday, May 14, 1999 8:52 AM
Posted To: Informix
Conversation: Cursors...
Subject: Cursors...
I have this situation:
DEFINE rec_a LIKE table_a.*
DEFINE rec_b LIKE table_b.*
DECLARE CURSOR cur_a FOR
SELECT * FROM table_a
FOREACH cur_a INTO rec_a.*
<Some elaboration>
DECLARE CURSOR cur_b FOR
SELECT * FROM table_b
WHERE table_b.key = rec_a.key
FOREACH cur_b INTO rec_b.*
<Some elaboration>
END FOREACH
END FOREACH
rec_a.key is key for table "table_b"
When i execute the 2nd FOREACH in rec_b i don't find the right
data, but
other non-sense data (non-sense relatively to the key I
correctly find with
the first foreach).
If, instead, i use the PREPARE statement to declare the 2nd
cursor, i
obtain the right values.
What does it happen?