Gary,

Your email sounds like you are executing an INSERT record command. 

The callback function is only called when you execute a SELECT and data is
returned as a result of your query.

Lee Crain

___________________________________________


-----Original Message-----
From: Gary G Allen [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 19, 2007 10:13 AM
To: sqlite-users@sqlite.org
Subject: [sqlite] Callback Function Not Working In Example Code

I appreciate the help yesterday. John Stanton's advice with the compiler
option got me going.

I have the example code from http://www.sqlite.org/quickstart.html
running. See code below.

However, the callback function is not getting executed.  Everything
looks correct to me and the callback function should be getting called.
I can create an instance where sqlite3_exec is executed properly and the
entry is made in the database.

Anyone have any suggestions to what might be going on?

Here are the compiler options I am using:
 %>gcc -o sql_test -lsqlite3 sql_test.c

Regards,
Gary


-------------
#include <stdio.h>
#include <sqlite3.h>

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

int main(int argc, char **argv){
  sqlite3 *db;
  char *zErrMsg = 0;
  int rc;

  if( argc!=3 ){
    fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
    exit(1);
  }
  rc = sqlite3_open(argv[1], &db);
  if( rc ){
    fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
    sqlite3_close(db);
    exit(1);
  }
  rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
  if( rc!=SQLITE_OK ){
    fprintf(stderr, "SQL error: %s\n", zErrMsg);
    sqlite3_free(zErrMsg);
  }
  sqlite3_close(db);
  return 0;
}

--------------------------------------------------------------------------
---
To unsubscribe, send email to [EMAIL PROTECTED]
--------------------------------------------------------------------------
---



-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to