Try OpenEdge Now
skip to main content
Programming Interfaces
Data Management : Database Access : Database aliases : Using shared record buffers with aliases
 
Using shared record buffers with aliases
Be careful when using shared buffers with aliases. If you reference a shared buffer after changing the alias that initially was used in defining it, a run-time error results. For example, consider the following procedures:
i-main2.p
CREATE ALIAS myalias FOR DATABASE sports1.
RUN i-makebuf.p.
i-makebuf.p
DEFINE NEW SHARED BUFFER mybuf FOR myalias.customer.

CREATE ALIAS myalias FOR DATABASE sports2.
RUN i-disp.p
i-disp.p
DEFINE SHARED BUFFER mybuf FOR myalias.Customer.

FOR EACH mybuf:
  DISPLAY mybuf.
END.
In this example, procedure i-main2.p calls i-makebuf.p, which in turn calls i-disp.p. The alias myalias is created in main.p, with reference to database sports1. In i-makebuf.p, the shared buffer mybuf is defined for the table myalias.Customer. Then, in the next line, myalias is changed, so that it now refers to database sports2. When an attempt is made to reference shared buffer mybuf in procedure i-disp.p, a run-time error occurs, with the message "i-disp.p unable to find shared buffer for mybuf."