1 #include "common.h" 2 3 /* Test for SQLMoreResults */ 4 5 static char software_version[] = "$Id: t0003.c,v 1.21 2011-07-12 10:16:59 freddy77 Exp $"; 6 static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; 7 8 static void DoTest(int prepared)9DoTest(int prepared) 10 { 11 odbc_command("create table #odbctestdata (i int)"); 12 13 /* test that 2 empty result set are returned correctly */ 14 if (!prepared) { 15 odbc_command("select * from #odbctestdata select * from #odbctestdata"); 16 } else { 17 CHKPrepare(T("select * from #odbctestdata select * from #odbctestdata"), SQL_NTS, "S"); 18 CHKExecute("S"); 19 } 20 21 CHKFetch("No"); 22 23 CHKMoreResults("S"); 24 printf("Getting next recordset\n"); 25 26 CHKFetch("No"); 27 28 CHKMoreResults("No"); 29 30 /* test that skipping a no empty result go to other result set */ 31 odbc_command("insert into #odbctestdata values(123)"); 32 if (!prepared) { 33 odbc_command("select * from #odbctestdata select * from #odbctestdata"); 34 } else { 35 CHKPrepare(T("select * from #odbctestdata select * from #odbctestdata"), SQL_NTS, "S"); 36 CHKExecute("S"); 37 } 38 39 CHKMoreResults("S"); 40 printf("Getting next recordset\n"); 41 42 CHKFetch("S"); 43 44 CHKFetch("No"); 45 46 CHKMoreResults("No"); 47 48 odbc_command("drop table #odbctestdata"); 49 50 ODBC_FREE(); 51 } 52 53 int main(int argc,char * argv[])54main(int argc, char *argv[]) 55 { 56 odbc_connect(); 57 58 DoTest(0); 59 DoTest(1); 60 61 odbc_disconnect(); 62 63 printf("Done.\n"); 64 return 0; 65 } 66