SQL$HELP_OLD72.HLB  —  SET_ALIAS
    Specifies the default alias for an SQL user session in
    dynamically prepared and executed or interactive SQL until
    another SET ALIAS statement is issued. If you do not specify
    an alias, the default is RDB$DBHANDLE.

1  –  Environment

    You can use the SET ALIAS statement:

    o  In interactive SQL

    o  Embedded in host language programs to be precompiled

    o  As part of a procedure in an SQL module

    o  In dynamic SQL as a statement to be dynamically executed

2  –  Format

  SET ALIAS ---+-> <alias-string-literal> --+->
               +-> <alias-parameter> -------+
               +-> <alias-parameter-marker> +

3  –  Arguments

3.1  –  alias-parameter

    Specifies a host language variable in precompiled SQL or a formal
    parameter in an SQL module language procedure that specifies the
    default alias.

3.2  –  alias-parameter-marker

    Specifies a parameter marker (?)  in a dynamic SQL statement. The
    alias parameter marker refers to a parameter that specifies the
    default alias.

3.3  –  alias-string-literal

    Specifies a character string literal that specifies the default
    alias. The alias string literal must be enclosed in single
    quotation marks.

4  –  Examples

    Example 1: Setting a default alias to avoid qualifying object
    names

    SQL> ATTACH 'ALIAS CORP FILENAME corporate_data';
    SQL> SET CATALOG 'ADMINISTRATION';
    SQL> SET SCHEMA 'PERSONNEL';
    SQL> SELECT LAST_NAME FROM EMPLOYEES;
    %SQL-F-NODEFDB, There is no default database
    SQL> --
    SQL> -- You must qualify the table name because you attached with an alias.
    SQL> --
    SQL> SELECT LAST_NAME FROM CORP.EMPLOYEES;
     LAST_NAME
     Ames
     Andriola
     Babbin
       .
       .
       .
    100 rows selected
    SQL> SET ALIAS 'CORP';
    SQL> --
    SQL> -- Now you do not need to qualify the table name EMPLOYEES.
    SQL> --
    SQL> SELECT LAST_NAME FROM EMPLOYEES;
     LAST_NAME
     Ames
     Andriola
     Babbin
       .
       .
       .
    100 rows selected

    Example 2: Changing the default alias

    Use the SHOW DATABASE statement to see the database settings.

    SQL> ATTACH 'FILENAME personnel';
    SQL> ATTACH 'ALIAS corp FILENAME corporate_data';
    SQL> --
    SQL> -- The default alias, RDB$DBHANDLE, refers to PERSONNEL
    SQL> -- to simplify references to CORPORATE_DATA make this
    SQL> -- database the default alias
    SQL> --
    SQL> SET ALIAS 'CORP';
       .
       .
       .
Close Help