Populating List Boxes with Procedures
Posted in 1996
Topics: Error Codes & Troubleshooting
I'm curious about what the recommended procedure might be for the following situation. I am populating some list boxes in a New Era program from dynamic tables (the number of records is unknown at any given time). I'd rather not create arrays for this but am using cursors defined in procedures. I'd gotten use to using such syntax as: FOREACH cursor ... END FOREACH or OPEN cursor using ... WHILE TRUE FETCH cursor ... IF sqlcode = 100 then exit while end if END WHILE CLOSE cursor However, I've noticed that procedures may put my program into an infinite loop if I'm not careful because the procedure will continue to return the values of the last row fetched after all rows have been fetched. Currently, I'm saving the value of the primary key in a local variable and testing subsequent rows against this value. If the subsequent value is the same I know my list box is populated and I can then proceed PREPARE exec_procedure ... DECLARE exec_curs ... let local_var = 0 OPEN exec_curs ... WHILE TRUE FETCH exec_curs into some_rec.* IF some_rec.primary_key = local_var then exit while ELSE let local_val = some_rec.primary_key END IF .... more code ... END WHILE CLOSE ... Anyway, I'm wondering if there is a more efficient approach. This system works but strikes me as a bit of a kludge. Thanks Scott H.