The functions sqlite3_sql() and sqlite3_expanded_sql() will return the original 
and expanded (i.e. with the bound values insted of parameter names) SQL strings 
for a statement created with the sqlite3_prepare_V2() interface.

-----Ursprüngliche Nachricht-----
Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im 
Auftrag von Igor Korot
Gesendet: Dienstag, 27. Dezember 2016 05:24
An: Discussion of SQLite Database <sqlite-users@mailinglists.sqlite.org>; 
General Discussion of SQLite Database <sqlite-us...@sqlite.org>
Betreff: [sqlite] How do I see a full query?

Hi, ALL,
I have a weird situation where executing a query in a shell gives me a row, but 
executing the same query through the C-interface: sqlite3_prepare_v2(),
sqlite3_bind_text() and sqlite3_step() produces SQLITE_DONE.

So I wonder - is it possible to see a full query string inside sqlite3_step()?

I'm using MSVC++2010 ATM with Windows 8.1. Program is compiled as 32-bit app.

From shell:
C:\Users\Igor\OneDrive\Documents>sqlite3 draft.db SQLite version 3.13.0 
2016-05-18 10:57:30 Enter ".help" for usage hints.
sqlite> SELECT * FROM "sys.abcattbl" WHERE "abt_tnam" = "leagues" AND "abt_ownr"
 = "";
leagues||||||||||||||||||||||||Leagues table
sqlite>

From the code routine (it is C++):

    sqlite3_stmt *stmt = NULL;
    std::wstring errorMessage;
    int result;
    std::wstring query = L"SELECT * FROM \"sys.abcattbl\" WHERE \"abt_tnam\" = 
? AND \"abt_ownr\" = \"\";";
    const unsigned char *dataFontName, *headingFontName, *labelFontName;
    int res = sqlite3_prepare_v2( m_db,
sqlite_pimpl->m_myconv.to_bytes( query.c_str() ).c_str(), (int) query.length(), 
&stmt, 0 );
    if( res == SQLITE_OK )
    {
        res = sqlite3_bind_text( stmt, 1, sqlite_pimpl->m_myconv.to_bytes( 
table->GetTableName().c_str() ).c_str(), -1, SQLITE_STATIC );
        if( res == SQLITE_OK )
        {
            while( true )
            {
                res = sqlite3_step( stmt );


where sqlite_pimpl is:

struct SQLiteDatabase::SQLiteImpl
{
    std::wstring m_catalog;
    std::wstring_convert<std::codecvt_utf8<wchar_t> > m_myconv; };

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

Reply via email to