Finally, I have managed to get the Mbeddded example working in VC++ 2005 Express Edition on Windows XP ! Thanks to the folks in the mailing list.
Use Case: MonetDB5 , Embedded Mode , SQL
To move towards the application I intend to experiment on, I need some more information:
1) How to make data durable? In the simple example, I tried the following:
a) First Run: Create table and insert rows. Select to check if everything is ok.
b) Second Run: Only perform selection
>> I get an error in the second run.
2) How to get meta data of the database?
a) I want to know the size of the tables and meta tables in the data base. In particular I am interested in seeing the growth of the database on addition of content.
b) Typically, there is a master table in the database that records information of the schema persisted. What is the name of the Master Table and its schema in MonetDB?
c) SQLite has an independent analyzer tool which dumps the state of the storage from which I can extract most of the data I need. Does MonetDB have a similar mechanism?
~Yuva
>>>> code snippet >>>>>
dbh = embedded_sql (set, setlen);
if (dbh == NULL || mapi_error(dbh))
die(dbh, hdl);
/* switch off autocommit */
if (mapi_setAutocommit(dbh, 0) != MOK || mapi_error(dbh))
die(dbh,NULL);
if ((hdl = mapi_query(dbh, "create table emp"
" (name varchar(20),age int)")) == NULL || mapi_error(dbh))
die(dbh, hdl);
close_handle(dbh,hdl);
for(i=0; i< 1000; i++) {
char query[100];
_snprintf(query, 100,"insert into emp values(\'user%d\', %d)", i, (i % 82));
if ((hdl = mapi_query(dbh, query)) == NULL || mapi_error(dbh))
die(dbh, hdl);
close_handle(dbh,hdl);
}
if ((hdl = mapi_query(dbh, "select * from emp")) == NULL || mapi_error(dbh))
die(dbh, hdl);
i=0;
while (mapi_fetch_row(hdl)) {
char *age = mapi_fetch_field(hdl, 1);
i= i+ atoi(age);
}
if (mapi_error(dbh))
die(dbh, hdl);
close_handle(dbh,hdl);
printf("The sum is %d \n",i);
mapi_disconnect(dbh);
return 0;