I tried to get error code 21 by using below code snippet. But didn't
get. Skipped sqlite3_reset() for 2 to 10,000 records.


code snippet:


int main()

{

   //create db connection and statement

   for(int i = 0; i < 10000; ++ i)

   {

       MyFunc(i, "abc", "def");

   }

   //finalize m_insert_stmt

   //close


   return 1;

}


bool MyFunc( const int col1, const char * const col2, const char * const col3)

{

        static bool reset_once = false;


        bool r = false;


        int nr = sqlite3_bind_int( m_insert_stmt, 1, col1 );


        if(SQLITE_OK != nr) return r;


        nr = sqlite3_bind_text( m_insert_stmt, 2, col2, strlen(col2),
SQLITE_STATIC );


        if(SQLITE_OK != nr) return r;


        nr = sqlite3_bind_text( m_insert_stmt, 3, col3, strlen( col3
), SQLITE_STATIC );


        if(SQLITE_OK != nr) return r;


        nr = sqlite3_step( m_insert_stmt );


        if(!reset_once)

              {

                   reset_once = true;

                   sqlite3_reset( m_insert_stmt );

              }


        return r;

}



On Mon, Mar 31, 2014 at 3:52 PM, d b <va230...@gmail.com> wrote:

> >>You might have failed to call sqlite3_reset()
>
> Here is the point. If my application gets any error(other than SQLITE_OK)
> during binding parameters for 11th record, function may return without
> sqlite3_reset. So, subsequent insertions may result same error. Am I right?
>
>
> On Mon, Mar 31, 2014 at 3:33 PM, d b <va230...@gmail.com> wrote:
>
>> My application calls sqlite3_finalize() after insertion of 10,000
>> record(loop). Is there any other reason?
>>
>>
>> On Mon, Mar 31, 2014 at 3:23 PM, d b <va230...@gmail.com> wrote:
>>
>>> sqlite3_bind_text() returned 21 error. It is throwing for all insertions
>>> once error introduced.
>>>
>>> For ex: Here, Inserted first 10 records successfully. then it was
>>> started throwing error 21 for 11th record on-wards till last record(10,000
>>> record). I was able to insert the records successfully after restart the
>>> application only.
>>>
>>>
>>> On Mon, Mar 31, 2014 at 2:23 PM, d b <va230...@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>>   I am getting sqlite error 21.
>>>>
>>>>
>>>>   There is only one sqlite prepared statement for insertion. It's not
>>>> multi threaded app. The below function repeatedly calling for every  record
>>>> insertion. This app was running from last 4 days. On third, it was started
>>>> throwing error 21. What could be the reason?
>>>>
>>>>   steps from application:
>>>>
>>>>   bool stmt::execute(const char* const insertquery, listofinputparams)
>>>>   {
>>>>
>>>>        insertquery is insert or replace into mystuff(id, name, value)
>>>> values(?,?,?);
>>>>
>>>>        bool r = false;
>>>>
>>>>       sqlite3_stmt s = find(insertquery);
>>>>
>>>>        while(enumerate listofinputparams)
>>>>        {
>>>>            bind each argument for insert statement s
>>>>        }
>>>>
>>>>        sqlite3_step(s);
>>>>
>>>>        sqlite3_reset(s);
>>>>
>>>>        return r;
>>>>   }
>>>>
>>>> Thanks,
>>>> a v
>>>>
>>>
>>>
>>
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to