I have a graphical interface which can display multiple SQLite query results in their own tabs. Now, I am finalizing a sqlite3_stmt
statement when the user closes its tab, not immediately. If there is more than one tab/result, the first one gives me exactly one sqlite3_stmt
, but the second one gives me two: the sqlite3_stmt
from the second tab, plus the one from the first tab. A third tab would give me 3 results, and so on.
Simplified Delphi code:
var
FHandle: sqlite3;
QueryResult: sqlite3_stmt;
begin
QueryResult := nil;
QueryStatus := sqlite3_prepare_v2(FHandle, SQL, -1, QueryResult, nil);
if QueryStatus = SQLITE_OK then begin
QueryResult := sqlite3_next_stmt(FHandle, nil);
while QueryResult <> nil do begin
while sqlite3_step(QueryResult) = SQLITE_ROW do begin
// store row data...
end;
// points to a previously prepared query:
QueryResult := sqlite3_next_stmt(FHandle, QueryResult);
end;
end;
end;
How do I only return the statement(s) from the just fired SQL, not from an earlier one?
Edit: I just tried sqlite3_prepare_v3
, which has a prepFlags
parameter where I can pass SQLITE_PREPARE_PERSISTENT
. But that did not seem to change anything here.