Why are buffers of reference-only tables not allowed as para

Posted by cverbiest on 11-Apr-2017 03:43

I'm wondering what's the reason behind the restrictions on reference-only buffers.

remove the comment // to get the errors

define temp-table t-refonly reference-only
    field tro_id as int.

run bind.p(table t-refonly bind).
//do for t-refonly: end.


procedure ShowId:
    //define parameter buffer bt-refonly for t-refonly.
end.

** Illegal nested block statement reference to table  t-refonly. (243)
**  Could not understand line 5. (196)                                

I wanted to to add the strong scoping to prevent usage of the default buffer, this works for other buffers but not for a bound temp-table.

Cannot use REFERENCE-ONLY buffer t-refonly as BUFFER parameter. (14303)
**  Could not understand line 9. (196)                                 

I"'m in the process of replacing a shared temp-table with a temp-table that is maintained by an object. In order to make the changes to legacy code  minimal I have provided a bind method that gives the legacy code access to the temp-table. Now I still have to rewrite half of the code because of this buffer parameter restriction.

All code using the temp-table binds to the same temp-table instance.

All Replies

Posted by Alex_u4a on 01-May-2017 08:09

With the BIND option, not only the temp-table but also the buffer is shared between different routines. So a find on the temp-table in the called routine would make it available as well in the calling routine.

So I think the first error makes sense since a reference to the buffer is (implicitly) made by using the BIND option outside the 'do for' block.

I am not sure why it is not possible to create a parameter buffer for a bound temp-table, but it is still possible to create a normal buffer for a bound temp-table. So maybe you can accomplish what you are trying to reach by doing a find on this buffer after the temp-table was send with the BIND option:

find bt-refonly where rowid(bt-refonly) = rowid(t-refonly).

This thread is closed