"Row value misused" error in SQLite database

Sqlite

Sqlite Problem Overview


I'm getting an error from an sqlite3 query for which I can't find any reference material. Googling the string takes me deep in the SQLite code itself, and that's so opaque I can't make heads or tails of it.

The table schema:

CREATE TABLE quote (
    seqnum INTEGER,
    session STRING,
    timestamp_sip INTEGER,
    timestamp_1 INTEGER,
    market_center STRING,
    symbol STRING,
    bid_price INTEGER,
    bid_lots INTEGER,
    offer_price INTEGER,
    offer_lots INTEGER,
    flags INTEGER,
    PRIMARY KEY (symbol, seqnum) );

The query:

select (seqnum, session, timestamp_sip, timestamp_1, market_center, symbol)
    from quote
    where symbol = 'QQQ';

The error:

> Error: row value misused

I have no idea how to proceed here. There is plenty of data in the table that would match the query:

sqlite> select count(*) from quote where symbol = 'QQQ';
2675931

Can anyone offer any guidance here? Sqlite version is 3.16.2.

Sqlite Solutions


Solution 1 - Sqlite

Nevermind. Those parentheses around the select columns (left over from a copy/paste) are the problem. Poor error message, maybe. But my fault.

Solution 2 - Sqlite

I had a similar when working with a Rails 5.2 Application.

For my case I was trying to write a search query for a model in application:

def self.search(params)
  applications = all.order('created_at DESC') # for not existing params args
  applications = applications.where("cast(id as text) like ?, email like ?, first_name like ?, last_name like ?, appref like ?", "#{params[:search]}", "%#{params[:search]}%", "#{params[:search]}", "#{params[:search]}", "#{params[:search]}",) if params[:search]
  applications
end

The issue was that I was using a comma (,) to separate the search parameters, I simply corrected by using an OR instead:

def self.search(params)
  applications = all.order('created_at DESC') # for not existing params args
  applications = applications.where("cast(id as text) like ? OR email like ? OR first_name like ? OR last_name like ? OR appref like ?", "#{params[:search]}", "%#{params[:search]}%", "#{params[:search]}", "#{params[:search]}", "#{params[:search]}",) if params[:search]
  applications
end

That's all.

I hope this helps

Solution 3 - Sqlite

I deleted brackets from query and it work for me: from SELECT (column1, column2, ...) FROM table to SELECT column1, column2, ... FROM table

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJohn SView Question on Stackoverflow
Solution 1 - SqliteJohn SView Answer on Stackoverflow
Solution 2 - SqlitePromise PrestonView Answer on Stackoverflow
Solution 3 - SqliteOtnielView Answer on Stackoverflow