An alias is a synonym for a logical database name. You use an alias as a database reference in ABL procedures in place of a logical database name.
You establish a logical database name when you connect a OpenEdge session to a physical database. You create and assign an alias to a logical database name of an already connected database using the CREATE ALIAS statement. By reassigning an alias to different logical database names, you can run a compiled procedure on other connected databases that have identical structure and time stamps or CRC values for the tables referenced by the procedure. A logical database name can have more than one alias, but each alias refers to only one logical database name at a time.
The OpenEdge Data Dictionary offers an example of alias usage. The OpenEdge Data Dictionary is a general-purpose OpenEdge application that works on any database that has DICTDB as an alias. The first database connected during a OpenEdge session automatically receives the alias DICTDB. During a OpenEdge session, you can reassign the DICTDB alias to another connected database with the Select Working Databases option on the Database menu in the OpenEdge Data Dictionary.
Note: Because of the need to reassign the DICTDB alias, OpenEdge does not allow you to run the OpenEdge Data Dictionary against a database connected with the logical name DICTDB.
Use the CREATE ALIAS statement during a OpenEdge session to assign or reassign an alias to a connected database. You can use this statement from the ABL editor or from an application procedure. This is the syntax for the CREATE ALIAS statement:
Syntax
CREATE ALIAS alias FOR DATABASE logical-name[NO-ERROR]
The alias argument can be an unquoted string, a quoted string, or an expression. The logical–name argument represents the existing logical name of a connected database. It can be an unquoted string, a quoted string, or an expression. You cannot create an alias that is the same as the logical database name of a connected database. The named database must be connected unless you use the NO–ERROR option.
When you create an alias, OpenEdge logs the alias assignment in a table that remains in memory for the current session. If you use the DISCONNECT statement to disconnect a database from within an application, all existing aliases assigned to the logical database name remain in the alias table until the end of the OpenEdge session. Later, if you connect to a database with the same logical database name during the same OpenEdge session, you can use the same aliases to reference that logical database name. If you create an alias that already exists in the session alias table, OpenEdge replaces the existing alias with the new alias. This allows you to reassign existing aliases to new logical database names.
The DELETE ALIAS statement allows you to delete an alias from the alias table of the current OpenEdge session. The following is the syntax for the DELETE ALIAS statement:
Syntax
DELETE ALIAS alias
The alias argument represents an alias that exists in the current alias session table.