Keith Medcalf Sent: Monday, December 18, 2017 1:07 PM To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org> Subject: Re: [sqlite] Odd question
>>I investigated a further while exploring some of the list >>suggestions. The app halts with an error unless >>sqlite3_column_count() > 0. That means I misspoke when I mentioned >>that the sql statement needed to return at least one row. I’m not >>sure if that makes a difference, though. > That makes a *huge* difference. sqlite3_column_count() is available after > the prepare and before the first step. Yes, the sqlite3_column_count() call happens after prepare() and before step(). >This means that the statement can be cancelled BEFORE it is executed >(step'ed). "returns no rows" can only be determined by running (step'ing) the >statement and requires the statement to be both prepared and run (and that it >returns SQLITE_DONE with no SQLITE_ROW). Right, all of the statements are step'd regardless of the result of sqlite3_column_count(). SQLITE_DONE is returned from the first step() for insert queries. >In the former case all statements which are not select/pragma statements >returning data do not have to be run. All the statements are run, the check for column count happens further downstream >In the latter case, all statements will be run and you will get the "no data >was returned" if no data was returned. Yes, all statements are run but the error comes from the fact that sqlite3_column_count() == 0 In pseudocode, it's prepare("insert...") //okay int num_col = sqlite3_column_count() //okay step() until sqlite_done //okay assert(num_col > 0) // blows up here, even though the query was successful So effectively I need sqlite3_column_count() > 0 in order to bypass the faulty assertion. Thanks for your help in pushing me to think about it and describe it more clearly- even if we don't find a solution it's a helpful conversation. ---------------------------------------------------------------------- This message, and any attachments, is for the intended recipient(s) only, may contain information that is privileged, confidential and/or proprietary and subject to important terms and conditions available at http://www.bankofamerica.com/emaildisclaimer. If you are not the intended recipient, please delete this message. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users