19.5.6 a_rdb_CNV_charVARBINARY() (convert to VARBINARY-type data)
- Organization of this subsection
(1) Function
This CLI function converts character string data in C or C++ to SQL VARBINARY-type data. The following figure shows an example of conversion from character string data to VARBINARY-type data.
- Important
-
The character string data before conversion must consist of one 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_charVARBINARY ( char *char_Data, /* In */ unsigned int char_Length, /* In */ unsigned short char_Type, /* In */ unsigned short VARBINARY_Length, /* In */ a_rdb_VARBINARY_t *VARBINARY_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 one of the following values:
-
When the character string data before conversion is in binary
1 to value of VARBINARY_Length × 8
-
When the character string data before conversion is in hexadecimal
1 to value of VARBINARY_Length × 2
-
- char_Type
-
Specifies the format of the character string data before conversion. Specify one of the following values:
-
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
-
- VARBINARY_Length
-
Specifies the length (in bytes) of the VARBINARY-type data after conversion. The permitted values are from 1 to 32,000.
- VARBINARY_Data
-
Specifies the start address of the area where the VARBINARY-type data after conversion is to be stored.
- BufferLength
-
Specifies the length (in bytes) of the area for storing the VARBINARY-type data after conversion. Specify the value of VARBINARY_Length + 2.
- Option
-
Specifies NULL. Any value that is specified is ignored.
(4) Return value
-
If a_rdb_CNV_charVARBINARY() 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 (char_Data) and the area for storing the data after conversion (VARBINARY_Data).
-
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
-
-
The character string data before conversion is converted to VARBINARY-type data, and then stored from the beginning of the storage area.