SQLite Forum

how to save results of
Login
static int callback_query1(void *NotUsed, int argc, char **argv, char **azColName)
{
   int i;
   for(i=0; i<argc; i++)
   {
      printf("%s = %s    ", azColName[i], argv[i] ? argv[i] : "NULL");
   }
   printf("\n");
   return 0;
}


const char *sql_query_tmp ="SELECT FrmNo,CapTime,CamTime from radar_1 WHERE FrmNo = %d ";
   char sql_query[200] = {0};
   sprintf(sql_query,sql_query_tmp,1);
   printf("query,radar_1,sql = %s\n",sql_query);

   rc = sqlite3_exec(db, sql_query, callback_query1, 0, &zErrMsg);
   if (rc != SQLITE_OK)
   {
      printf("sql inquery error, %s", sqlite3_errmsg(db));

      sqlite3_free(zErrMsg);
   }
    


the code inquire the table well, and the call back function print the correct data.

BUT,how do I save this results into array or file? since callback function have no interface in sqlite3_exec(),should I write in this way

rc = sqlite3_exec(db, sql_query, callback_query1(p1,p2,...,etc), 0, &zErrMsg);

I feel it is a bit hard for a newbie to learn sqlite3, since few examples are available from the office website,in fact,even a few examples are helpful for a starter, 

Any help will be appricated