Hitachi

Hitachi Advanced Database SQL Reference


6.4.2 CURRENT_TIME

Returns the current time.

Organization of this subsection

(1) Specification format

datetime-information-acquisition-function-CURRENT_TIME ::= CURRENT_TIME[(p)]

(2) Rules

  1. The fractional seconds precision (the number of digits to the right of the decimal point) is specified in p. You can specify the value 0, 3, 6, 9, or 12 for p. For example, when p is 3, there will be 3 digits in the fractional seconds of the execution result of CURRENT_TIME.

  2. If (p) is omitted, p = 0 is assumed.

  3. The data type of the execution result is the TIME type.

  4. Specifying CURRENT_TIME multiple times in an SQL statement produces the same time value.

  5. The value of CURRENT_TIME is acquired when the SQL statement is executed on the HADB server. For details about interfaces and execution methods for executing SQL statements, see the descriptions of the JDBC API, ODBC functions, and CLI functions in the HADB Application Development Guide.

  6. The precision of the fractional seconds acquired by CURRENT_TIME depends on the capabilities of the hardware. For example, if you specify CURRENT_TIME(12), depending on the hardware you are using you might not be able to acquire 12 digits of fractional seconds precision.

    Example:

    10:35:55.123456000000

    As shown above, if only 6 digits of fractional seconds precision can be acquired, the 7th and subsequent digits will be 0.

  7. CURRENT_TIME can be specified in places where a value specification can be specified.

(3) Examples

Example

Add product sales information to the daily sales history table (SALESLIST_DAY). The columns in the sales history table are shown below. The current time is stored as the time goods are sold (SALE_TIME).

  • Store code (SCODE)

  • Goods code (GCODE)

  • Sex of customer (SEX)

  • Time of sale of goods (SALE_TIME)

INSERT INTO "SALESLIST_DAY"
      ("SCODE","GCODE","SEX","SALE_TIME")
    VALUES('S001','G03542','M',CURRENT_TIME)