NCBI C++ ToolKit
t0001.c
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #include "common.h"
2 
3 #include <common/test_assert.h>
4 
5 static char software_version[] = "$Id: t0001.c 80645 2017-12-28 17:20:38Z ucko $";
7 
8 int
9 main(int argc, char *argv[])
10 {
11 
12  int i;
13 
15 
16  const char *command;
17  SQLCHAR output[256];
18 
19  odbc_connect();
20 
21  odbc_command("if object_id('tempdb..#odbctestdata') is not null drop table #odbctestdata");
22 
23  command = "create table #odbctestdata ("
24  "col1 varchar(30) not null,"
25  "col2 int not null,"
26  "col3 float not null," "col4 numeric(18,6) not null," "col5 datetime not null," "col6 text not null)";
28 
29  command = "insert #odbctestdata values ("
30  "'ABCDEFGHIJKLMNOP',"
31  "123456," "1234.56," "123456.78," "'Sep 11 2001 10:00AM'," "'just to check returned length...')";
33 
34  odbc_command("select * from #odbctestdata");
35 
36  CHKFetch("SI");
37 
38  for (i = 1; i <= 6; i++) {
39  CHKGetData(i, SQL_C_CHAR, output, sizeof(output), &cnamesize, "S");
40 
41  printf("output data >%s< len_or_ind = %d\n", output, (int) cnamesize);
42  if (cnamesize != strlen((char *) output))
43  return 1;
44  }
45 
46  CHKFetch("No");
47 
48  CHKCloseCursor("SI");
49 
50  odbc_command("drop table #odbctestdata");
51 
53 
54  printf("Done.\n");
55  return 0;
56 }
#define CHKGetData(a, b, c, d, e, res)
Definition: common.h:136
#define odbc_command(cmd)
Definition: common.h:179
#define CHKCloseCursor(res)
Definition: common.h:100
#define CHKFetch(res)
Definition: common.h:118
int main(int argc, char **argv)
Definition: t0001.c:13
#define SQLLEN
Definition: odbc.h:52
static SQLRETURN odbc_connect(TDS_DBC *dbc, TDSLOGIN *login)
Definition: odbc.c:356
int odbc_disconnect(void)
Definition: common.c:290
static SQLCHAR output[256]
Definition: print.c:5
static SQLINTEGER cnamesize
Definition: stats.c:8
static void * no_unused_var_warn[]
Definition: t0001.c:6
static char software_version[]
Definition: t0001.c:5
int i
const char * command
#define SQL_C_CHAR
Definition: sqlext.h:511
unsigned char SQLCHAR
Definition: sqltypes.h:125
Modified on Fri Sep 20 14:57:56 2024 by modify_doxy.py rev. 669887