Note that there are some explanatory texts on larger screens.

plurals
  1. POPreparing statements in SQLite3 using the C++ API always fails
    primarykey
    data
    text
    <p>Preparing a SQL stament using <code>sqlite3_prepare_v2()</code> always returns error code <code>SQLITE_MISUSE</code>. Although I read my code about a thousand times, I couldn't find any error. Here's a MWE. </p> <pre><code>#include &lt;sqlite3.h&gt; int main() { int rc = sqlite3_initialize(); sqlite3 *db = NULL; // Constant name of the database. const char* dbName = "symplectic.db"; // We open the database file and initialize the pointer to it. int errorCode; errorCode = sqlite3_open_v2(dbName, &amp;db,SQLITE_OPEN_READWRITE,NULL); errorCode = sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS TBIntegrators \n" "(" "IndexIntegrator INTEGER PRIMARY KEY AUTOINCREMENT, \n" "INTDescription CHARACTER(8), \n" "INTOrder INTEGER, \n" "INTStepsizeType INTEGER \n" "); \n" "INSERT INTO TBIntegrators (INTDescription, INTOrder, INTStepsizeType) VALUES ('RK4',4,0);\n" "INSERT INTO TBIntegrators (INTDescription, INTOrder, INTStepsizeType) VALUES ('SIFS4',4,0);\n" "INSERT INTO TBIntegrators (INTDescription, INTOrder, INTStepsizeType) VALUES ('SIFS8',8,0);\n" "INSERT INTO TBIntegrators (INTDescription, INTOrder, INTStepsizeType) VALUES ('SIVS4-1',4,1);\n" "INSERT INTO TBIntegrators (INTDescription, INTOrder, INTStepsizeType) VALUES ('SIVS8-1',8,1);\n" "CREATE TABLE IF NOT EXISTS TBSimuInstance\n" "(" "IndexSimuInstance INTEGER PRIMARY KEY AUTOINCREMENT,\n" "SIMIndexIntegrator INTEGER REFERENCES TBIntegrators (IndexIntegrator));\n" "CREATE TABLE IF NOT EXISTS TBData\n" "(" "IndexData INTEGER PRIMARY KEY AUTOINCREMENT,\n" "DATIndexSimuInstance INTEGER REFERENCES TBSimuInstance (IndexSimuInstance),\n" "DAT_TimeInPeriods UNSIGNED BIG INT,\n" "DATPosX DOUBLE,\n" "DATPosY DOUBLE,\n" "DATMomX DOUBLE,\n" "DATMomY DOUBLE \n" ")", NULL, NULL, NULL); rc = sqlite3_prepare_v2(db, "INSERT INTO TBSimuInstance (SIMIndexIntegrator) VALUES (:int)", -1, &amp;insertInstance, NULL); return 0; } </code></pre> <p>The last <code>rc</code> always comes back as <code>SQLITE_MISUSE</code>, but the SQL is legal (I tested it in the command line interface). I also removed any <code>_</code> characters, thinking that my SQL command strings were not properly escaped. </p> <p>Anyhow, am I missing something stupid?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload