Hitachi

Hitachi Advanced Database Application Development Guide


19.5.7 a_rdb_CNV_BINARYchar() (convert BINARY-type data)

Organization of this subsection

(1) Function

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

Figure 19‒7: Example of conversion from BINARY-type data to character string data

[Figure]

Explanation:

This example converts BINARY-type data to the character string literal described below and then stores the result from the beginning of the storage area. Null characters (0x00) are added at the end.

  • When the format of the character string after conversion is in binary: Binary literal in binary format

  • When the format of the character string after conversion is in hexadecimal: Binary literal in hexadecimal format

(2) Format

#include <adbcnv.h>
 
signed short a_rdb_CNV_BINARYchar
(
  unsigned char                  *BINARY_Data,      /* In  */
  unsigned short                  BINARY_Length,    /* In  */
  unsigned short                  char_Type,        /* In  */
  char                           *char_Data,        /* Out */
  unsigned int                    BufferLength,     /* In  */
  void                           *Option            /* In  */
)

(3) Arguments

BINARY_Data

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

BINARY_Length

Specifies the length (in bytes) of the BINARY-type data before conversion. The permitted values are from 1 to 32,000.

char_Type

Specifies the format of the character string data after conversion. Specify one of the following values:

  • When the format of the character string data after conversion is in binary

    a_rdb_CNV_CHAR_TYPE_BINARY

  • When the format of the character string data after conversion is in hexadecimal

    a_rdb_CNV_CHAR_TYPE_HEX

char_Data

Specifies the start address of 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 following value:

  • When the format of the character string data after conversion is in binary

    value of BINARY_Length × 8 + 1

  • When the format of the character string data after conversion is in hexadecimal

    value of BINARY_Length × 2 + 1

Option

Specifies NULL. Any value that is specified is ignored.

(4) Return value

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