Hitachi

Hitachi Advanced Database Application Development Guide


19.5.11 a_rdb_CNV_TIMESTAMPchar() (convert TIMESTAMP-type data)

Organization of this subsection

(1) Function

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

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

[Figure]

Explanation:
  • This example converts TIMESTAMP-type data to character string data according to the predefined output representation that represents a time stamp. For details about the predefined output representation for time stamps, see the topic Predefined character-string representations in the manual HADB SQL Reference.

  • Null characters (0x00) are added at the end.

(2) Format

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

(3) Arguments

TIMESTAMP_Data

Specifies the start address of the area where the TIMESTAMP-type data before conversion is stored.

TIMESTAMP_Scale

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

char_Data

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

BufferLength

Specifies the length (in bytes) of the area where the character string after conversion is to be stored. Specify one of the following values:

  • If the fractional seconds precision for the TIMESTAMP-type data to be converted is 0: 20

  • If the fractional seconds precision for the TIMESTAMP-type data to be converted is 3, 6, 9, or 12: 20 + TIMESTAMP_Scale value + 1

Option

Specifies NULL.

(4) Return value

  1. If a_rdb_CNV_TIMESTAMPchar() 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

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