0

Mistakenly I have put a double value divided by zero in an SQLite database column.

In "DB Browser", it looks like string "Inf" or "inf". However, "WHERE MY_COLUMN = 'inf'" gives no result.

How can I retrieve all records containing this value via an SQL query?

Also, how can I identify this value in the cursor loop?

I have tried these:

cursor.getString(cursor.getColumnIndex(MY_COLUMN)).equalsIgnoreCase("inf")

cursor.getDouble(cursor.getColumnIndex(MY_COLUMN)) == Double.POSITIVE_INFINITY

No result as well.

prazuber
  • 1,352
  • 10
  • 26
Oleh Romanenko
  • 289
  • 1
  • 11
  • What's the `typeof()` the value? TEXT or REAL? – Shawn Mar 11 '19 at 23:58
  • In the database, the column is declared as NUMERIC. The typeof() for the values containing 'inf' returns 'text' both in "DB Browser" and the code. – Oleh Romanenko Mar 12 '19 at 00:27
  • Shawn, thank you so much for your idea. I just added a selection column TYPE_COLUMN and queried the table with "TYPE_COLUMN = 'text'". This gave me the records I needed. If you put this as an answer, I will accept it. – Oleh Romanenko Mar 12 '19 at 09:31
  • It turned out that the 'Inf' value is of the REAL type, and the 'inf' value is of the TEXT type. I managed to handle the TEXT ones, however still googling on how I can select the REALs... – Oleh Romanenko Mar 15 '19 at 09:18
  • 1
    Try this: select * from my_table where my_column * my_column = my_column and my_column != 0 – Andres Y. Mar 20 '19 at 21:31
  • What a trick! Sorry, just noticed your comment. Is it safe? Does it work the same way everywhere? In the DB Browser, it works fine. (I'd also add "and my_column != 1") – Oleh Romanenko Dec 01 '19 at 18:32

0 Answers0