I like "Generate Table API" functionality.
However your code is not sorted by column_id it looks you forgot order by. It's very important to have all sorted by definition of columns in table.
I suggest to add extra new "sel" API which returns record by PK and stores it in rec type.
Regards
Tomasz