The example code in this section shows utility functions to which the DataDirect functions for bulk exporting, verification, and bulk loading refer, as well as the DataDirect functions GetBulkDiagRec and GetBulkDiagRecW.
GetBulkDiagRec and GetBulkDiagRecW
Syntax
SQLReturn
GetBulkDiagRec (SQLSMALLINT HandleType,
SQLHANDLE Handle,
SQLSMALLINT RecNumber,
SQLCHAR* Sqlstate,
SQLINTEGER* NativeError,
SQLCHAR* MessageText,
SQLSMALLINT BufferLength,
SQLSMALLINT* TextLength);
GetBulkDiagRecW (SQLSMALLINT HandleType,
SQLHANDLE Handle,
SQLSMALLINT RecNumber,
SQLWCHAR* Sqlstate,
SQLINTEGER* NativeError,
SQLWCHAR* MessageText,
SQLSMALLINT BufferLength,
SQLSMALLINT* TextLength);
The standard ODBC return codes are returned: SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_INVALID_HANDLE, SQL_NO_DATA, and SQL_ERROR.
Purpose
GetBulkDiagRec (ANSI application) and GetBulkDiagRecW (Unicode application) return errors and warnings generated by bulk operations. The argument definition, return values, and function behavior is the same as for the standard ODBC SQLGetDiagRec and SQLGetDiagRecW functions with the following exceptions:
• The GetBulkDiagRec and GetBulkDiagRecW functions can be called after a bulk load, export or validate function is invoked to retrieve any error messages generated by the bulk operation. Calling these functions after any function except a bulk function is not recommended.
• The values returned in the Sqlstate and MessageText buffers by the GetBulkDiagRecW function are encoded as UTF-16 on Windows platforms. On UNIX and Linux platforms, the values returned for Sqlstate and MessageText are UTF-16 if the value of the SQL_ATTR_APP_UNICODE_TYPE is SQL_DD_CP_UTF16 and UTF-8 if the value of SQL_ATTR_APP_UNICODE_TYPE is SQL_DD_CP_UTF8.
• The handle passed as the Handle argument must be a driver connection handle obtained by calling SQLGetInfo (<ODBC Conn Handle>, SQL_DRIVER_HDBC).
• SQL_HANDLE_DBC is the only value accepted for HandleType. Any other value causes an error to be returned.
Example
#include "qesqlext.h"
#ifndef NULL
#define NULL 0
#endif
#if (! defined (_WIN32)) && (! defined (_WIN64))
typedef void * HMODULE;
#endif
/* Get the address of a routine in a shared library or DLL. */