Hitachi

Hitachi Advanced Database Command Reference


38.6.1 Example

This example executes the INSERT statement which uses dynamic parameters to add a row.

Organization of this subsection

(1) Adding rows with the VALUES specification

COMMAND ?     +----2----+----3----+----4----+----5----+----6----+----7----+
INSERT INTO T1 VALUES(?,?,?);                     ...1
 DATA (    1) ? : SMALLINT                        ...2
COMMAND ?     +----2----+----3----+----4----+----5----+----6----+----7----+
25000;                                            ...3
 DATA (    2) ? : VARCHAR (   10)                 ...2
COMMAND ?     +----2----+----3----+----4----+----5----+----6----+----7----+
'HITACHI';                                        ...3
 DATA (    3) ? : TIMESTAMP (    7)               ...2
COMMAND ?     +----2----+----3----+----4----+----5----+----6----+----7----+
TIMESTAMP'2011-02-23 12:00:00';                   ...3
KFAA96404-I 1 rows were inserted. COMMAND ?     +----2----+----3----+----4----+----5----+----6----+----7----+
COMMIT;                                           ...4
KFAA96403-I SQL processing completed.
Explanation:
  1. Executes the INSERT statement using dynamic parameters.

  2. Displays a request for entry of data for a dynamic parameter in the following format:

    DATA (aa...aa) ?:bb...bb

    aa...aa: Sequence number of the dynamic parameter from the beginning of the SQL statement.

    bb...bb: Data type assumed by the dynamic parameter. One of the following is displayed:

    INTEGER

    SMALLINT

    DECIMAL (precision,scaling)

    DOUBLE PRECISION

    CHAR (length)

    VARCHAR (length)

    DATE (length)

    TIME (length)

    TIMESTAMP (length)

    BINARY (length)

    VARBINARY (length)

  3. Specifies a literal, which must be consistent with the data type assumed by the dynamic parameter. For the rules for input data, see 38.6.2 Input data specification rules.

  4. Executes COMMIT to finalize addition of the row by the INSERT statement.

(2) Adding data by row (ROW specification)

COMMAND ?     +----2----+----3----+----4----+----5----+----6----+----7----+
INSERT INTO "T1" (ROW) VALUES(?);                 ...1
 DATA (    1) ? : ROW (   10)                     ...2
COMMAND ?     +----2----+----3----+----4----+----5----+----6----+----7----+
X'0A000000000000003132';                          ...3
KFAA96404-I 1 rows were inserted. COMMAND ?     +----2----+----3----+----4----+----5----+----6----+----7----+
COMMIT;                                           ...4
KFAA96403-I SQL processing completed.
Explanation:
  1. Executes the INSERT statement with a dynamic parameter specified.

  2. Displays a message in the following format requesting entry of input data for a dynamic parameter:

    DATA (aa...aa) ?:ROW (length)

    aa...aa: Sequence number of the dynamic parameter specified in the SQL statement.

  3. Entry of a literal using the correct data type that is assumed by the dynamic parameter. For the rules for input data, see 38.6.2 Input data specification rules.

  4. Executes COMMIT and finalizes addition of the row by the INSERT statement.