Hitachi

Hitachi Advanced Database Application Development Guide


19.5.10 a_rdb_CNV_TIMEchar() (convert TIME-type data)

Organization of this subsection

(1) Function

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

Figure 19‒10: Example of conversion from TIME-type data to character string data

[Figure]

Explanation:
  • This example converts TIME-type data to character string data according to the predefined output representation that represents time. For details about the predefined output representation for time, 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_TIMEchar
(
  unsigned char         *TIME_Data,               /* In  */
  unsigned short         TIME_Scale,              /* In  */
  char                  *char_Data,               /* Out */
  unsigned short         BufferLength,            /* In  */
  void                  *Option                   /* In  */
)

(3) Arguments

TIME_Data

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

TIME_Scale

Specifies the fractional seconds precision for the TIME-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 TIME-type data before conversion is 0: 9

  • If the fractional seconds precision for the TIME-type data before conversion is 3, 6, 9, or 12: 9 + TIME_Scale value + 1

Option

Specifies NULL. Any value that is specified is ignored.

(4) Return value

  1. If a_rdb_CNV_TIMEchar() 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 (TIME_Data) and the area for storing the data after conversion (char_Data).