SQL$HELP72.HLB  —  DECLARE  ALIAS  Examples
    Example 1: Specifying a database and an alias in embedded SQL

    This statement declares the database defined by the file
    specification personnel. The precompiler uses this definition
    when compiling the program and SQL uses the file personnel when
    the program runs. This name may be a logical name or the name
    portion of the file personnel.rdb.

    EXEC SQL
           DECLARE PERS_ALIAS ALIAS FOR FILENAME personnel
    END-EXEC

    Example 2: Specifying a database with restricted access

    This statement is the same as Example 1, but specifies restricted
    access to the database.

    EXEC SQL
           DECLARE PERS_ALIAS ALIAS FOR FILENAME personnel
           RESTRICTED ACCESS
    END-EXEC

    Example 3: Specifying the DECLARE ALIAS statement

    This portion of an application program declares the databases
    MIA1 and MIA_CHAR_SET. The precompiler uses the MIA1 database
    when compiling the program and SQL uses the MIA_CHAR_SET database
    when the program runs.

    EXEC SQL
             DECLARE ALIAS
          COMPILETIME FILENAME MIA1
                 RUNTIME FILENAME MIA_CHAR_SET
                 DEFAULT CHARACTER SET DEC_KANJI
                 NATIONAL CHARACTER SET KANJI;

    Example 4: Specifying the DEFAULT user authentication

    The following example shows how to use the DEFAULT clause for
    user name and password in an SQL module:

    MODULE             TEST_DECLARE
    DIALECT            SQL99
    LANGUAGE           C
    PARAMETER          COLONS
    ALIAS              RDB$DBHANDLE
    -------------------------------------------------------
    -----------------------declarations--------------------
        DECLARE ALIAS COMPILETIME FILENAME mf_personnel
                      USER DEFAULT
                      USING DEFAULT
        RUNTIME :run_time_spec
       .
       .
       .

    You pass the compile-time user name and password to the program
    by using command line qualifiers. For example, to compile the
    program use the following command line:

    $ SQLMOD TESTDEC /USER=heleng /PASS= helenspasswd

    At run time, the host language program can prompt the run-
    time user to specify only the file specification or the file
    specification and the user name and password at run time. The
    host language program can build the run time string.

    For example, if the host language program uses only the file
    specification, the value of the variable passed to the program
    can be the following:

    FILENAME "mf_personnel"

    If the host language program uses the file specification, user
    name and password, the value of the variable passed to the
    program can be the following:

    FILENAME "mf_personnel 'USER heleng' USING 'mypassword' "

    You must enclose the string in quotation marks; whether you
    use single (') or double quotation marks (") depends upon the
    programming language.

    If you use the following DECLARE ALIAS statement, the host
    language program can only prompt the run-time user to specify
    the file name.

        DECLARE ALIAS COMPILETIME FILENAME mf_personnel
                      USER DEFAULT
                      USING DEFAULT
        RUNTIME FILENAME :foo
Close Help