Question

I am implementing parameter queries for sqlite in C++ and I want to have the DatabaseCallback updated when I execute. I know it is possible when your query is a string but is it possible when it is a sqlite3_stmt? Note: sql is my select string

            DatabaseCallback* pCallback;
            sqlite3_stmt *stmt;
            const char *pzTest;
            int selectCommand = sqlite3_prepare_v2(database_, sql.c_str(), strlen(sql.c_str()), &stmt, &pzTest);

            if(selectCommand == SQLITE_OK)
            {
                //Add the parameter values
                int parameterPosition = 1;

                if(parameters.size() > 0)
                {
                    size_t count = parameters.size();
                    for(string str : parameters)
                    {
                        int returncode = sqlite3_bind_text(stmt,parameterPosition, str.c_str(), strlen(str.c_str()),SQLITE_TRANSIENT);
                        parameterPosition++;
                    }

                }
            }

            sqlite3_step(stmt);
            sqlite3_finalize(stmt);
Was it helpful?

Solution

You are supposed to call sqlite3_step multiple times, and get the values with the sqlite3_column_* functions in each step.

If you really want to have the same behaviour as sqlite3_exec, just copy its implementation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top