19.5.12 a_rdb_CNV_VARBINARYchar() (convert VARBINARY-type data)
- Organization of this subsection
(1) Function
This CLI function converts SQL VARBINARY-type data to character string data in C or C++. The following figure shows an example of conversion from VARBINARY-type data to character string data.
- Explanation:
-
This example converts VARBINARY-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 of the data.
-
When the format of the character string data after conversion is in binary: Binary literal in binary format
-
When the format of the character string data after conversion is in hexadecimal: Binary literal in hexadecimal format
-
(2) Format
#include <adbcnv.h> signed short a_rdb_CNV_VARBINARYchar ( a_rdb_VARBINARY_t *VARBINARY_Data, /* In */ unsigned short VARBINARY_Length, /* In */ unsigned short char_Type, /* In */ char *char_Data, /* Out */ unsigned int BufferLength, /* In */ void *Option /* In */ )
(3) Arguments
- VARBINARY_Data
-
Specifies the start address of the area where the VARBINARY-type data before conversion is stored.
- VARBINARY_Length
-
Specifies the length (in bytes) of the VARBINARY-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 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:
-
When the format of the character string data after conversion is in binary
value of VARBINARY_Length × 8 + 1
-
When the format of the character string data after conversion is in hexadecimal
value of VARBINARY_Length × 2 + 1
-
- Option
-
Specifies NULL. Any value that is specified is ignored.
(4) Return value
-
If a_rdb_CNV_VARBINARYchar() terminates normally, a_rdb_RC_CNV_SUCCESS is returned.
-
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 (VARBINARY_Data) and the area for storing the data after conversion (char_Data).