Hitachi

Hitachi Advanced Database Command Reference


38.3.2 Executing an SQL statement specified in a file

This example uses the CREATE TABLE statement to define table T1.

  1. Specify the CREATE TABLE statement in the file (infile).

    ADBUSER01                                     ...1
    #HelloHADB_01                                 ...2
    CREATE FIX TABLE "T1"                         ...3
      ("C1" INT,"C2" CHAR(10),"C3" CHAR(7))
      IN DBAREA01;
    Explanation:

    1. Specifies on the file's first line the authorization identifier of an HADB user with the CONNECT privilege and the schema definition privilege.

    2. Specifies on the second line the password for the authorization identifier of the HADB user.

    3. Specifies the CREATE TABLE statement. Make sure that you enter a semicolon (;) at the end of the SQL statement.

  2. Start the adbsql command.

    adbsql -V < infile

    This example specifies the -V option to display the SQL statement that is executed.

  3. Check the execution results.

      USER-ID ?
    ADBUSER01
     
      PASSWORD ?
    COMMAND ?     +----2----+----3----+----4----+----5----+----6----+----7----+
    CREATE FIX TABLE "T1"                     ...1
    NEXT ?        +----2----+----3----+----4----+----5----+----6----+----7----+
      ("C1" INT,"C2" CHAR(10),"C3" CHAR(7))   ...1
    NEXT ?        +----2----+----3----+----4----+----5----+----6----+----7----+
      IN DBAREA01;                            ...1
    KFAA96403-I SQL processing completed. ...2
    COMMAND ?     +----2----+----3----+----4----+----5----+----6----+----7----+
    Explanation:

    1. Displays the executed SQL statement because the -V option was specified.

    2. A message indicating that the CREATE TABLE statement has executed successfully is displayed.

Important points
  • Make sure that the text in the file is encoded in the character encoding specified in the ADBCLTLANG environment variable.

  • For the line-ending code, use X'0A' (LF) or X'0D0A' (CRLF).

  • #EXIT is executed automatically even if you omit #EXIT and #DISCONNECT from the file.

  • If the adbsql command's #DISCONNECT and #EXIT subcommands are preceded by an EOF control character, the DISCONNECT processing is performed at that point.

  • For the password, 1 to 255 bytes of characters can be specified.