NCBI C++ ToolKit
Classes | Macros | Typedefs | Functions | Variables
bcp.c File Reference
#include "common.h"
#include <odbcss.h>
#include <common/test_assert.h>
+ Include dependency graph for bcp.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

struct  prefixed_int
 
struct  prefixed_str
 

Macros

#define TDSODBC_BCP
 
#define VARCHAR_BIND(x)
 
#define INT_BIND(x)    bcp_bind( odbc_conn, (unsigned char *) (prefixlen == 0 ? (void*)&x.value : &x), prefixlen, SQL_VARLEN_DATA, NULL, termlen, BCP_TYPE_SQLINT4, col++ )
 
#define NULL_BIND(x, type)    bcp_bind( odbc_conn, (unsigned char *) (prefixlen == 0 ? (void*)&x.value : &null_prefix), prefixlen, prefixlen == 0 ? SQL_NULL_DATA : SQL_VARLEN_DATA, NULL, termlen, type, col++ )
 

Typedefs

typedef char bcp_init_char_t
 

Functions

static void init (void)
 
static void test_bind (int prefixlen)
 
static void set_attr (void)
 
static void report_bcp_error (const char *errmsg, int line, const char *file)
 
static void normal_inserts (int prefixlen)
 
static void normal_select (void)
 
static void special_inserts (void)
 
static void special_select (void)
 
int main (int argc, char *argv[])
 

Variables

static struct prefixed_int not_null_bit = {4, 1}
 
static struct prefixed_str not_null_char = {64, "a char"}
 
static struct prefixed_str not_null_varchar = {64, "a varchar"}
 
static struct prefixed_str not_null_datetime = {64, "2003-12-17 15:44:00.000"}
 
static struct prefixed_str not_null_smalldatetime = {64, "2003-12-17 15:44:00"}
 
static struct prefixed_str not_null_money = {64, "12.34"}
 
static struct prefixed_str not_null_smallmoney = {64, "12.34"}
 
static struct prefixed_str not_null_float = {64, "12.34"}
 
static struct prefixed_str not_null_real = {64, "12.34"}
 
static struct prefixed_str not_null_decimal = {64, "12.34"}
 
static struct prefixed_str not_null_numeric = {64, "12.34"}
 
static struct prefixed_int not_null_int = {4, 1234}
 
static struct prefixed_int not_null_smallint = {4, 1234}
 
static struct prefixed_int not_null_tinyint = {4, 123}
 
static struct prefixed_str not_null_nvarchar = {64, "a wide var"}
 
static ODBCINT64 null_prefix = -1
 
static const char * expected []
 
static const int total_cols = 29
 
static const char * expected_special []
 
static int tds_version
 
static const char table_name [] = "all_types_bcp_unittest"
 

Macro Definition Documentation

◆ INT_BIND

#define INT_BIND (   x)     bcp_bind( odbc_conn, (unsigned char *) (prefixlen == 0 ? (void*)&x.value : &x), prefixlen, SQL_VARLEN_DATA, NULL, termlen, BCP_TYPE_SQLINT4, col++ )

Definition at line 141 of file bcp.c.

◆ NULL_BIND

#define NULL_BIND (   x,
  type 
)     bcp_bind( odbc_conn, (unsigned char *) (prefixlen == 0 ? (void*)&x.value : &null_prefix), prefixlen, prefixlen == 0 ? SQL_NULL_DATA : SQL_VARLEN_DATA, NULL, termlen, type, col++ )

Definition at line 144 of file bcp.c.

◆ TDSODBC_BCP

#define TDSODBC_BCP

Definition at line 2 of file bcp.c.

◆ VARCHAR_BIND

#define VARCHAR_BIND (   x)
Value:
(unsigned char *) (prefixlen == 0 ? (void*)&x.value : &x), \
prefixlen, (SQLINTEGER) strlen(x.value), NULL, termlen, \
BCP_TYPE_SQLVARCHAR, col++ )
HDBC odbc_conn
Definition: common.c:32
#define NULL
Definition: ncbistd.hpp:225
RETCODE bcp_bind(DBPROCESS *dbproc, BYTE *varaddr, int prefixlen, DBINT varlen, BYTE *terminator, int termlen, int db_vartype, int table_column)
Bind a program host variable to a database column.
Definition: bcp.c:2032
long SQLINTEGER
Definition: sqltypes.h:176

Definition at line 135 of file bcp.c.

Typedef Documentation

◆ bcp_init_char_t

typedef char bcp_init_char_t

Definition at line 10 of file bcp.c.

Function Documentation

◆ init()

static void init ( void  )
static

Definition at line 62 of file bcp.c.

References odbc_command, and tds_version.

Referenced by main().

◆ main()

int main ( int  argc,
char *  argv[] 
)

◆ normal_inserts()

static void normal_inserts ( int  prefixlen)
static

Definition at line 289 of file bcp.c.

References bcp_batch(), bcp_done(), bcp_init(), bcp_sendrow(), FAIL, i, NULL, odbc_conn, report_bcp_error(), T, table_name, and test_bind().

Referenced by main().

◆ normal_select()

static void normal_select ( void  )
static

Definition at line 382 of file bcp.c.

References CHKCloseCursor, CHKFetch, CHKGetData, exit(), expected, i, odbc_command, ok, output, SQL_C_CHAR, SQL_NULL_DATA, SQLLEN, util::strcmp(), and total_cols.

Referenced by main().

◆ report_bcp_error()

static void report_bcp_error ( const char *  errmsg,
int  line,
const char *  file 
)
static

Definition at line 238 of file bcp.c.

References file, NULL, odbc_report_error(), and odbc_stmt.

Referenced by normal_inserts(), and special_inserts().

◆ set_attr()

static void set_attr ( void  )
static

Definition at line 232 of file bcp.c.

References odbc_conn, and SQLSetConnectAttr.

Referenced by main().

◆ special_inserts()

static void special_inserts ( void  )
static

◆ special_select()

static void special_select ( void  )
static

Definition at line 414 of file bcp.c.

References CHKCloseCursor, CHKFetch, CHKGetData, exit(), expected_special, i, odbc_command, ok, output, SQL_C_CHAR, SQLLEN, and util::strcmp().

Referenced by main().

◆ test_bind()

static void test_bind ( int  prefixlen)
static

Variable Documentation

◆ expected

const char* expected[]
static

◆ expected_special

const char* expected_special[]
static
Initial value:
= {
"2015-03-14 15:26:53.000",
"2015-03-14 15:26:53.589793",
"3.141593000",
"3.141593",
"",
}

Definition at line 51 of file bcp.c.

Referenced by special_select().

◆ not_null_bit

struct prefixed_int not_null_bit = {4, 1}
static

Definition at line 10 of file bcp.c.

Referenced by special_inserts(), and test_bind().

◆ not_null_char

struct prefixed_str not_null_char = {64, "a char"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_datetime

struct prefixed_str not_null_datetime = {64, "2003-12-17 15:44:00.000"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_decimal

struct prefixed_str not_null_decimal = {64, "12.34"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_float

struct prefixed_str not_null_float = {64, "12.34"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_int

struct prefixed_int not_null_int = {4, 1234}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_money

struct prefixed_str not_null_money = {64, "12.34"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_numeric

struct prefixed_str not_null_numeric = {64, "12.34"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_nvarchar

struct prefixed_str not_null_nvarchar = {64, "a wide var"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_real

struct prefixed_str not_null_real = {64, "12.34"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_smalldatetime

struct prefixed_str not_null_smalldatetime = {64, "2003-12-17 15:44:00"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_smallint

struct prefixed_int not_null_smallint = {4, 1234}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_smallmoney

struct prefixed_str not_null_smallmoney = {64, "12.34"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_tinyint

struct prefixed_int not_null_tinyint = {4, 123}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ not_null_varchar

struct prefixed_str not_null_varchar = {64, "a varchar"}
static

Definition at line 10 of file bcp.c.

Referenced by test_bind().

◆ null_prefix

ODBCINT64 null_prefix = -1
static

Definition at line 40 of file bcp.c.

◆ table_name

const char table_name[] = "all_types_bcp_unittest"
static

◆ tds_version

int tds_version
static

◆ total_cols

const int total_cols = 29
static

Definition at line 49 of file bcp.c.

Referenced by normal_select().

Modified on Fri Sep 20 14:58:11 2024 by modify_doxy.py rev. 669887