SQLite Forum

sqlite3_exec stepping through multiple queries
The solution might be quite messy in practice so much so as to warrant the prohibition of  multiple queries by simply having the callback function returning non-zero when the column names are different.

Any intricate solution involving multiple queries is likely to run out of memory.

It is not enough to know which of a set of multiple queries is being executed since that can happen within the callback function and no callback happens when there are no results to be returned. Neither 'DROP TABLE xyz;' nor 'SELECT * FROM MYTABLE WHERE 0=1;' will see the callback being invoked.

The reason for asking the question in the first place was this: imagine a GUI application that stores its inputs by screen/form. It can request those values either one at a time i.e. per screen/form or it can request values for all screens in one go. The callback function needs to build the results by screen/form- easy with single requests but 'messy' with multiple requests at once not least because sqlite3_exec does not hand back control to the application until the callback has processed all queries.