Le Sat, 19 Sep 2015 15:21:44 +0200,
Kees Nuyt <k.nuyt at zonnet.nl> a ?crit :

> On Sat, 19 Sep 2015 11:29:37 +0200, gwenn <gwenn.kahz at gmail.com>
> wrote:
> 
> >Hello,
> >Is there any way to know when a prepared statement is recompiled ?
> >For example:
> >
> >rc = sqlite3_prepare_v2(db, "SELECT * FROM test", -1, &stmt, NULL);
> >...
> >cc = sqlite3_column_count(stmt);
> >...
> >rc = sqlite3_exec(db, "ALTER TABLE test ADD COLUMN data DEFAULT
> >'missing'", NULL, NULL, NULL);
> >...
> >rc = sqlite3_step(stmt);
> >// how to know that the column count is not good anymore ?
> 
> http://www.sqlite.org/rescode.html#schema
> 


not sure if I understand, but If you just add a column, 

  int i;

  while ( i!=SQLITE_DONE )
  {
    i = sqlite3_step( stmt );

    switch( i )
    {

      case SQLITE_DONE :
      {
        /* then the column was added so you implicitly know
           the count has changed : */
        cc = sqlite3_column_count(stmt);
        break;

      }


      default :
      {
        std::cout << "(EE) " << i << " not expected!" << std::endl;
        /*...*/
      }

    }

  }

also I may have wrong but for me you are mixing `sqlite3_exec` and 
`sqlite3_prepare_v2`. For my
your strategy is wrong.

regards,
nicolas

Reply via email to