Hitachi

Hitachi Advanced Database Application Development Guide


19.5.5 a_rdb_CNV_charTIMESTAMP() (convert to TIMESTAMP-type data)

Organization of this subsection

(1) Function

This CLI function converts character string data in C or C++ to SQL TIMESTAMP-type data. The following figure shows an example of conversion from character string data to TIMESTAMP-type data.

Figure 19‒5: Example of conversion from character string data to TIMESTAMP-type data

[Figure]

Important

The character string data before conversion must be in a predefined input representation that represents a time stamp. For details about the predefined input representations for time stamps, see the topic Predefined character-string representations in the manual HADB SQL Reference.

Example:

The character string data that represents 19:06:48 on September 30, 2014, must be in one of the following formats:

2014-09-30 19:06:48

2014/09/30 19:06:48

(2) Format

#include <adbcnv.h>
 
signed short a_rdb_CNV_charTIMESTAMP
(
  char                  *char_Data,                  /* In  */
  unsigned short         char_Length,                /* In  */
  unsigned short         TIMESTAMP_Scale,            /* In  */
  unsigned char         *TIMESTAMP_Data,             /* Out */
  unsigned short         BufferLength,               /* In  */
  void                  *Option                      /* In  */
)

(3) Arguments

char_Data

Specifies the start address of the area where the character string data before conversion (character string data in C or C++) is stored.

char_Length

Specifies the length (in bytes) of the character string data before conversion. Specify a value in the range from 19 to 19 + value of TIMESTAMP_Scale + 1.

TIMESTAMP_Scale

Specifies the fractional seconds precision for the TIMESTAMP-type data after conversion. Specify 0, 3, 6, 9, or 12.

TIMESTAMP_Data

Specifies the start address of the area where the TIMESTAMP-type data after conversion is to be stored.

BufferLength

Specifies the length (in bytes) of the area where the TIMESTAMP-type data after conversion is to be stored. Specify 7 + ↑value of TIMESTAMP_Scale ÷ 2↑.

Option

Specifies NULL.

(4) Return value

  1. If a_rdb_CNV_charTIMESTAMP() terminates normally, a_rdb_RC_CNV_SUCCESS is returned.

  2. If an error occurs, the error code is returned as the return value. For details about the error code, see 19.8 Return values of the CLI functions.

(5) Notes

  1. You must ensure that there is no overlap between the area for storing the data before conversion (char_Data) and the area for storing the data after conversion (TIMESTAMP_Data).

  2. The character string data before conversion is converted to TIMESTAMP-type data, and then stored from the beginning of the storage area. If the fractional seconds precision for the character string data to be converted is not 3, 6, 9, or 12, zeros are padded to the right of the data until the fractional seconds precision specified for TIMESTAMP_Scale is reached.