FINALLY block and accessing a single column from a DB table

Posted by ericg on 27-Sep-2012 14:23

Greetings.

Interesting find when using a FINALLY block inside an iterating block.

If the iterating block is with a DB table buffer then accessing a single column in the FINALLY block will give a runtime error of 91 (no record is available), but no error if accessing the whole record.

FOR EACH dbTable:

    FINALLY:

        DISPLAY AVAIL(dbTable). /* always yes */

        DISPLAY TableID. /* error */

/*

        DISPLAY dbTable. /* no error */

*/

    END.

END.

If iterating through a temp-table and accessing a single column then no error.

FOR EACH ttTable:

    FINALLY:

        DISPLAY TableID. /* no error */

    END.

END.

All Replies

Posted by Admin on 28-Sep-2012 05:10

It might have something to do with buffer scoping, if you keep the display available(table) then the error is gone... compile with xref and if there is a 'reference' to that table inside the finally block then accessing the field does not raise an error, if it's just the field access then the error shows.

Anyway, imho finally only purpose should be 'clean-up'... you'll get there even if there was an error or not, in the first case an undo was already performed... why are you trying to accomplish there?

Posted by ericg on 28-Sep-2012 12:23

Hi Marian, I think that is part of my point where if you don't have the AVAILABLE(...) statement then we get the error where clearly the code shows there shouldn't be an error in the iteration. So that doesn't seem right? But I do agree that FINALLY blocks do need to make sure that a record is available in case of entering in an error state but in this case there shouldn't be an error. I guess I should mark this one as a peculiarity.

This thread is closed