Re: [sqlite] How do I check if the DB is open?

2016-12-14 Thread Jens Alfke

> On Dec 13, 2016, at 8:01 PM, Igor Korot  wrote:
> 
> Yes, you are correct.
> Do you know how I can write such a code?

Just move the code that looks for statements into the " if( res != SQLITE_OK )” 
block.

—Jens
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] How do I check if the DB is open?

2016-12-14 Thread Hick Gunter
Perhaps you should change your calling sequence so that you call 
sqlite3_next_stmt() BEFORE sqlite3_close()? If you exclusively use 
sqlte3_prepare_v2() you can retrieve the text of the unfinalized statement(s), 
print/log that, and maybe even call sqlite3_finalize() if you like.

-Ursprüngliche Nachricht-
Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im 
Auftrag von Igor Korot
Gesendet: Mittwoch, 14. Dezember 2016 01:55
An: Discussion of SQLite Database ; 
General Discussion of SQLite Database 
Betreff: [sqlite] How do I check if the DB is open?

Hi, ALL,
I'm using following code to check for errors in debug mode:

int res = sqlite3_close( m_db );
if( res != SQLITE_OK )
{
// error handling
}
#ifdef DEBUG
sqlite3_stmt *statement = sqlite3_next_stmt( m_db, NULL );
if( statement )
const char *query = sqlite3_sql( statement ); #endif

However the call to sqlite3_close() make the 'm_db' pointer invalid if 
everything is successful and hence the sqlite3_next_stmt() crashes.

How do I properly check if the DB is still open?
Or maybe I should put the code inside #ifdef#endif before DB closing?

Thank you.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___
 Gunter Hick
Software Engineer
Scientific Games International GmbH
FN 157284 a, HG Wien
Klitschgasse 2-4, A-1130 Vienna, Austria
Tel: +43 1 80100 0
E-Mail: h...@scigames.at

This communication (including any attachments) is intended for the use of the 
intended recipient(s) only and may contain information that is confidential, 
privileged or legally protected. Any unauthorized use or dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please immediately notify the sender by return e-mail message and 
delete all copies of the original communication. Thank you for your cooperation.


___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users