Try OpenEdge Now
skip to main content
Programming Interfaces
Data Management : Database Access : Database aliases : Creating aliases in applications
Creating aliases in applications
You cannot assign and reference an alias in the same procedure. You must assign an alias to a logical database name prior to compiling and running procedures that use that alias. For example, the procedure in i-alias1.p fails to compile when it reaches the FOR EACH statement, because you cannot assign and reference the alias myalias in a single procedure.
/* Note that this procedure does not work */
CREATE ALIAS myalias FOR DATABASE sports2000.

FOR EACH myalias.Customer NO-LOCK:
  DISPLAY Customer.
To solve this problem, split i-alias1.p into two procedures, as in the following examples:
CREATE ALIAS myalias FOR DATABASE sports2000.
RUN i-dispcust.p.
FOR EACH myalias.Customer NO-LOCK:   /* myalias.Customer */
  DISPLAY Customer.                  /* myalias.Customer */