c++ - SQLITE_MISUSE in prepared statement -
i'm getting sqlite_misuse error on following code, , wondering if might caused having table name bound parameter? different causes of sqlite_misue?
const char sqlneuralstateinsert[] = "insert ?1(layer_id, neuron_id, input_id, value)" "values(?2, ?3, ?4, ?5);"; sqlite3_stmt* stmt1; rc = sqlite3_prepare_v2(db, sqlneuralstateinsert, -1, &stmt1, null); if(rc){ //!< failed prepare insert statement } sqlite3_bind_text(stmt1, 1, this->getnname().c_str(), -1, sqlite_static); for(uint32_t = 0; < m_nlayers; i++){ sqlite3_bind_int(stmt1, 2, i); // layer id for(uint32_t j = 0; j < m_layers[i]->getneuroncount(); j++){ std::vector<double> weights = m_layers[i]->getweights(j); sqlite3_bind_int(stmt1, 3, j); // neuron id for(uint32_t k = 0; k < weights.size(); k++){ sqlite3_bind_int(stmt1, 4, k); sqlite3_bind_double(stmt1, 5, weights[k]); rc = sqlite3_step(stmt1); printf("%d\n", rc); } } } sqlite3_finalize(stmt1);
you're right; you cannot bind table name:
generally 1 cannot use sql parameters/placeholders database identifiers (tables, columns, views, schemas, etc.) or database functions (e.g.,
current_date
), instead binding literal values.
you have trivially tested hypothesis hard-coding table name.
Comments
Post a Comment