About cursors...
Posted in 1999
I have to do some clarification about cursors.
I need the second declaration of cursor (i agree with the fact it is not
the right thing, but...) because first i did this thing:
DEFINE rec_a LIKE table_a.*
DEFINE rec_b LIKE table_b.*
DECLARE CURSOR cur_a FOR
SELECT * FROM table_aFOREACH cur_a INTO rec_a.*
<Some elaboration 1>
SELECT * INTO rec_b.* FROM table_b
WHERE table_b.key = rec_a.key
<Some elaboration 2>
END FOREACH
But in this way i didn't find anything right in rec_b because rec_a didn't
contain the right key. Then i try with the second cursor...
I found this is because in <Some Elaboration 1> i assigned to
some variables named "key" particular values. (Pratically I used the same
name for variables and key columns in table_b).
Perhaps this confuses 4GL and so it leads to bad results.
I changed the names of the variables and all works well.
I'm sorry for not reporting what was written in section <Some elaboration
1> but i thought it wasn't important...
I thanks everyone anyway.
Bye Guido