title: “Library Routine Called Out Of Sequence” sqlite3_prepare_v2(CREATE TABLE)
body: <p>Do you know why do I get “Library Routine Called Out Of Sequence” when I call <code>sqlite3_prepare_v2(CREATE TABLE)</code> on an empty database?</p>
  
  <p>I create an empty database and then open it. Later I save all information that has to be written to the database in RAM (I need to save that information in RAM and flush it to permanent storage at the end of execution), but I get this error message when I call <code>sqlite3_prepare_v2(CREATE TABLE)</code>. It returns  “Library Routine Called Out Of Sequence” as an error message. </p>
  
  <p>I do open my database correctly and (I thought that it can be a problem so I did <code>close()</code> my DB and then <code>open()</code> right before calling <code>sqlite3_prepare_v2(CREATE TABLE)</code>). I thought it could be because of thread concurrency, but using critical section didn't help too.  </p>