1 #include "common.h"
2 
3 static char software_version[] = "$Id: t0001.c,v 1.19 2010-07-05 09:20:33 freddy77 Exp $";
4 static void *no_unused_var_warn[] = { software_version, no_unused_var_warn };
5 
6 int
main(int argc,char * argv[])7 main(int argc, char *argv[])
8 {
9 
10 	int i;
11 
12 	SQLLEN cnamesize;
13 
14 	const char *command;
15 	SQLCHAR output[256];
16 
17 	odbc_connect();
18 
19 	odbc_command("if object_id('tempdb..#odbctestdata') is not null drop table #odbctestdata");
20 
21 	command = "create table #odbctestdata ("
22 		"col1 varchar(30) not null,"
23 		"col2 int not null,"
24 		"col3 float not null," "col4 numeric(18,6) not null," "col5 datetime not null," "col6 text not null)";
25 	odbc_command(command);
26 
27 	command = "insert #odbctestdata values ("
28 		"'ABCDEFGHIJKLMNOP',"
29 		"123456," "1234.56," "123456.78," "'Sep 11 2001 10:00AM'," "'just to check returned length...')";
30 	odbc_command(command);
31 
32 	odbc_command("select * from #odbctestdata");
33 
34 	CHKFetch("SI");
35 
36 	for (i = 1; i <= 6; i++) {
37 		CHKGetData(i, SQL_C_CHAR, output, sizeof(output), &cnamesize, "S");
38 
39 		printf("output data >%s< len_or_ind = %d\n", output, (int) cnamesize);
40 		if (cnamesize != strlen((char *) output))
41 			return 1;
42 	}
43 
44 	CHKFetch("No");
45 
46 	CHKCloseCursor("SI");
47 
48 	odbc_command("drop table #odbctestdata");
49 
50 	odbc_disconnect();
51 
52 	printf("Done.\n");
53 	return 0;
54 }
55