0

As shown from the SQLite site, sqlite3_exec calls callback at every record returned for some action:

int sqlite3_exec(
sqlite3*,                                  /* An open database */
const char *sql,                           /* SQL to be evaluated */
int (*callback)(void*,int,char**,char**),  /* Callback function */
void *,                                    /* 1st argument to callback */
char **errmsg                              /* Error msg written here */

);

Is it possible to invoke another self defined function to do a different set of actions on every record instead of editing the callback function?

For example, sqlite3_exec(db, sql, display, 0, &zErrMsg);, where display is a function to display all records in the terminal.

EDIT: I thought about overloading the function, but I don't think C supports overloading.

1
  • C does not support overloading, but it does allow for repeated function arguments, (using the ellipsis, ..., operator). However, have you considered using the callback function to simply call another function that would, as you suggest, display all records in the terminal? Commented Jan 23, 2014 at 23:10

1 Answer 1

1

It is possible to use another function, like this:

sqlite3_exec(db, sql, display, 0, &zErrMsg);

The name "callback" is just the name of the parameter as used internally by the sqlite3_exec function; your own functions can be named whatever you like.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.