Hitachi

Hitachi Advanced Database Command Reference


38.3.3 Outputting the SQL statement's execution results to a file

This example uses the SELECT statement to search table USERSLIST, and outputs the execution results to a file (outfile).

  1. Start the adbsql command.

    adbsql -V > outfile

    This example specifies the -V option to output the SQL statement to be executed to a file (outfile).

  2. Specifies the authorization identifier.

    adbsql -V > outfile
    ADBUSER01Specify the authorization identifier of the HADB user, and then press the Enter key.

    Specify the authorization identifier of an HADB user who has the CONNECT privilege and who has the SELECT privilege for table USERSLIST. This HADB user authorization identifier is used to connect to the HADB server.

  3. Enter the password.

    adbsql -V > outfile
    ADBUSER01
             ← Specify the password for the authorization identifier, and then press the Enter key.

    Specify the password for the authorization identifier of the HADB user that connects to the HADB server. The entered characters are not displayed.

  4. Execute the SELECT statement

    adbsql -V > outfile
    ADBUSER01
    SELECT "USERID","NAME","SEX" FROM "USERSLIST";
  5. Terminate the adbsql command.

    adbsql -V > outfile
    ADBUSER01
    SELECT "USERID","NAME","SEX" FROM "USERSLIST";
    #EXIT;

    This example executes the adbsql command's #EXIT subcommand to terminate the adbsql command.

  6. The SELECT statement execution results are output to the file (outfile).

      USER-ID ?
    ADBUSER01
     
      PASSWORD ?
    COMMAND ?     +----2----+----3----+----4----+----5----+----6----+----7----+
    SELECT "USERID","NAME","SEX" FROM "USERSLIST";        ...1
     USERID NAME                           SEX            ...2
     ------ ------------------------------ ---
     U00555 Mike Johnson                     M
     U00358 Nancy White                      F
     U00212 Maria Gomez                      F
     U00687 Taro Tanaka                      M
     U00869 Bob Clinton                      M
    KFAA96404-I 5 rows were selected. COMMAND ?     +----2----+----3----+----4----+----5----+----6----+----7----+
    #EXIT;
    Explanation:

    1. This is the executed SELECT statement.

    2. The lines beginning with this line are the execution results of the SELECT statement. For the display format of SQL statement execution results, see 38.7 Output format of SQL statement execution results.

The text output to the file is encoded in the character encoding specified in the ADBCLTLANG environment variable.

The entry history of adbsql subcommands is also output to the file.