*** empty log message ***
[csql.git] / test / dbapi / Table / bindtest1.c
blob909a6bf3f946fdd8f3d3a2fa3da03dc3502120ad
1 #include<CSql.h>
2 //bind non exisiting field
3 int main()
5 Connection conn;
6 DbRetVal rv = conn.open("root", "manager");
7 if (rv != OK) return 1;
8 DatabaseManager *dbMgr = conn.getDatabaseManager();
9 if (dbMgr == NULL) { printf("Auth failed\n"); return 2;}
11 TableDef tabDef;
12 tabDef.addField("f1", typeInt, 0, NULL, true);
13 tabDef.addField("f2", typeInt);
14 tabDef.addField("f3", typeString, 20);
15 rv = dbMgr->createTable("t1", tabDef);
16 if (rv != OK) { printf("Table creation failed\n"); conn.close(); return 3; }
17 printf("Table created\n");
19 Table *table = dbMgr->openTable("t1");
20 if (table == NULL)
22 printf("Unable to open table\n");
23 dbMgr->dropTable("t1");
24 conn.close();
25 return -1;
27 int id1 = 0, id2 = 5;
28 int ret =0;
29 char name[20] = "PRAVEEN";
30 rv = table->bindFld("f1", &id1);
31 if (rv != OK) ret = 1;
32 rv = table->bindFld("f5", &id2);
33 if (rv == OK) ret = 1;
34 dbMgr->closeTable(table);
35 dbMgr->dropTable("t1");
36 conn.close();
37 return ret;