Exemple #1
0
string Sql::query(string query)
{
    if(dbSQLite==false)
    {
//        throw(QString("SqlJson::query: database not connected: "+query.toString()));
    }
    int rc;
    sqlite3_stmt *stmt=NULL;
    rc=prepare(dbSQLite,query,&stmt);
    if(rc!=SQLITE_OK)
    {
 //       throw(errmsg(dbSQLite)+": "+query.toString());
    }
    rc=step(stmt);
    if(rc!=SQLITE_DONE) if(rc!=SQLITE_OK) if(rc!=SQLITE_ROW)
    {
   //     throw(errmsg(dbSQLite)+": "+query.toString());
    }
    int numCols=column_count(stmt);
    while(rc==SQLITE_ROW)
    {
        for(int i=0;i<numCols;i++)
        {
            column_text(stmt,i);
        }
        rc=step(stmt);
    }
    finalize(stmt);
    return("");
}
Exemple #2
0
/// Type-checked version of column_text.
///
/// \param name The name of the column to retrieve.
///
/// \return The same as column_text if the value can be retrieved.
///
/// \throw error If the type of the cell to retrieve is invalid.
/// \throw invalid_column_error If name is invalid.
std::string
sqlite::statement::safe_column_text(const char* name)
{
    const int column = column_id(name);
    if (column_type(column) != sqlite::type_text)
        throw sqlite::error(F("Column '%s' is not a string") % name);
    return column_text(column);
}