Hitachi

Hitachi Advanced Database Application Development Guide


19.5.1 a_rdb_CNV_charBINARY() (convert to BINARY-type data)

Organization of this subsection

(1) Function

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

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

[Figure]

Important

The character string data before conversion must consist of the following values:

  • When the character string data before conversion is in binary

    0 and 1

  • When the character string data before conversion is in hexadecimal

    0 to 9 and A to F (or a to f)

(2) Format

#include <adbcnv.h>
 
signed short a_rdb_CNV_charBINARY
(
  char                          *char_Data,         /* In  */
  unsigned int                   char_Length,       /* In  */
  unsigned short                 char_Type,         /* In  */
  unsigned short                 BINARY_Length,     /* In  */
  unsigned char                 *BINARY_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 the following value:

  • When the character string data before conversion is in binary

    1 to value of BINARY_Length × 8

  • When the character string data before conversion is in hexadecimal

    1 to value of BINARY_Length × 2

char_Type

Specifies the format of the character string data before conversion. Specify the following value:

  • When the character string data before conversion is in binary

    a_rdb_CNV_CHAR_TYPE_BINARY

  • When the character string data before conversion is in hexadecimal

    a_rdb_CNV_CHAR_TYPE_HEX

BINARY_Length

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

BINARY_Data

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

BufferLength

Specifies the length (in bytes) of the area for storing the BINARY-type data after conversion. Specify the same value as for BINARY_Length.

Option

Specifies NULL. Any value that is specified is ignored.

(4) Return value

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

  2. The length of the character string data before conversion must satisfy one of the following conditions:

    • When the character string data before conversion is in binary: Multiple of 8

    • When the character string data before conversion is in hexadecimal: Multiple of 2

  3. The character string data before conversion is converted to BINARY-type data, and then stored from the beginning of the storage area. If the character string data to be converted is smaller than the following value, 0x00 is padded to the right of the data:

    • When the character string data before conversion is in binary: Value of BINARY_Length × 8

    • When the character string data before conversion is in hexadecimal: Value of BINARY_Length × 2